在eLisp的函数中设置变量

时间:2016-04-09 03:40:40

标签: function lisp elisp

尝试将函数和列表传递给函数。尝试将列表中的每个项目与以下项目进行比较。

功能是:

(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

我一直收到错误 - 设置constant-t

1 个答案:

答案 0 :(得分:2)

t是保留名称(请参阅11.2 Variables that never change)。使用一个不同的变量名来代替t,它可以告诉它包含/含义(例如firstItem)。

相关问题