试图将函数和列表传递给函数。正在尝试将列表中的每个项目与以下项目进行比较。
功能是:
(defun my-list-function(fn L)
(if (< (length L) 2)
(message "List needs to be longer than 2")
(progn (setq newL L) ;; Save the list locally
(while (> (length newL) 1) ;; While list has 2 items
(setq t (car newL)) ;; Get first item
(setq newL (cdr newL)) ;; resave list minus first item
(funcall #'fn t #'car newL))))) ;; pas first two items to a function
我一直收到一个错误-设置常量t
t
是一个保留名称(请参阅11.2永远不变的变量)。使用不同的变量名来代替t
,告诉它包含/意味着什么(例如firstItem
)。
(setq newL L) ;; Save the list locally
这不会在本地保存。newL
不是局部变量。setq
不声明局部变量。setq
将变量设置为某个值。