从列表pl中读取多项式(参见下面的输入格式)并将其作为排序列表返回。
示例:(ReadPolynomial2 '(99 0 17 200 3 150 8 200 0 0))
应返回((99 0) (3 150) (25 200))
答案 0 :(得分:0)
我不知道你是否还需要它,但这里有一个可能的解决方案:
(defun ReadPolynomial2 (lst)
(let ((even-positions (loop for p in (cdr lst) by #'cddr collect p)))
(loop for p in (remove-duplicates even-positions)
collect (list (loop for x on lst by #'cddr
when (= p (second x))
sum (first x)) p))))