我想要一个谓词作为函数的参数。
(DEFUN per (F L)
(cond ((F L) 'working)
(T 'anything)))
(per 'numberp 3)
结果它引发了一个错误:
表格中未定义的运算符F(F L)。
答案 0 :(得分:4)
如Technical Issues of Separation in Function Cells and Value Cells中所述,
Common Lisp是一个Lisp-2,即你
需要funcall
:
core.es5.js:1084 ERROR Error: Uncaught (in promise): Response with status: 404 Not Found for URL: http://localhost:4200/mock_data/data.json
另见apply
。
答案 1 :(得分:0)
晚会,但这是另一个例子:
(defun strip-predicate (p list)
(cond ((endp list) nil)
((funcall p (first list)) (strip-predicate (rest list)))
( T (cons (first list) (strip-Predicate p (rest list))))))
这可以用于谓词,例如atom或numberp:
(strip-predicate 'numberp '(a 1 b 2 c 3 d))
(a b c d)
或:
(strip-predicate 'atom '(a (a b) b c d))
((a b))