【发布时间】:2020-05-12 05:27:38
【问题描述】:
(defun *smaller* (x y)
( if (> x y) y
x))
(defun *minimum* (lst)
(do ((numbers lst (cdr numbers))
(result (car numbers) (*smaller* result (car numbers))))
((null numbers) result)))
LISP 说“最小”函数中的变量“数字”是未绑定的,尽管我认为我已将其绑定到“lst”。我错过了什么?
【问题讨论】:
-
我知道,这个可能是为了教育,但是使用
reduce不是更好吗?只是(reduce #'*smaller* lst)? -
另外,在函数名中使用
*earmuffs*是反习惯用法,因为这种风格通常用于特殊变量。 -
感谢您提供的信息,我对编码很陌生。是的,这是我的 uni 课程的作业,我不是 Comp sci 学生。
标签: lisp common-lisp unbound