从lisp中的整数列表中消除x的每次出现

-2 lisp function common-lisp

我需要编写一个lisp函数来消除整数列表中每次出现的x.例如,(elim 7'(7 6 8 8 7 7 9 0))返回(6 8 8 9 0)

Jos*_*lor 7

你不需要写它; 它已经为你写了,它被称为remove:

CL-USER> (remove 7 '(7 6 8 8 7 7 9 0))
;=> (6 8 8 9 0)
Run Code Online (Sandbox Code Playgroud)

如果你真的需要它被调用elim,你可以使用(setf fdefinition):

CL-USER> (setf (fdefinition 'elim) (fdefinition 'remove))
;=> ...
CL-USER> (elim 7 '(7 6 8 8 7 7 9 0))
;=> (6 8 8 9 0)
Run Code Online (Sandbox Code Playgroud)