在 eLisp 的函数中设置变量
setting a variable in a function in 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
我一直收到错误 - 设置常量 t
t
是保留名称(参见 11.2 Variables that never change)。使用不同的变量名称而不是 t
来说明它是什么 contains/means(例如 firstItem
)。
(setq newL L) ;; Save the list locally
这不会保存本地。 newL
不是局部变量。 setq
没有声明局部变量。 setq
将变量设置为某个值。
正在尝试将函数和列表传递给函数。正在尝试将列表中的每个项目与以下项目进行比较。
函数是:
(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 Variables that never change)。使用不同的变量名称而不是 t
来说明它是什么 contains/means(例如 firstItem
)。
(setq newL L) ;; Save the list locally
这不会保存本地。 newL
不是局部变量。 setq
没有声明局部变量。 setq
将变量设置为某个值。