`(disivible '(1 2 3 4 5 6 7))。这是我到目前为止所做的:
(defun divisible(n)
(cond ((eq n 0) nill) (eq(rem n 3) 0) t )('else 0)))
但我是 lisp 的新手,我不知道如何让它不显示可被 3 整除的数字,而只是添加数字并显示结果。有人可以帮帮我吗?
最佳答案
(defun divisible (num-list)
(reduce #'+
(remove-if-not #'zerop
num-list
:key (lambda (x)
(mod x 3)))))
关于Lisp 可分性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20595135/