【发布时间】:2010-04-18 11:30:54
【问题描述】:
这里有个小问题我快疯了,
我不断收到错误,我似乎无法弄清楚为什么,
该代码应该更改列表的范围,
因此,如果我们给它一个包含值 (1 2 3 4) 的列表,并且我们想要将范围从 11 更改为 14,那么结果将是 (11 12 13 14)
问题是最后一个名为scale-list 的函数会返回一个错误:
调试器进入--Lisp 错误: (wrong-type-argument number-or-marker-p nil)
有人知道为什么吗? 我使用 aquamacs 作为编辑器 提前致谢
;;finds minimum in a list
(defun minimum (list)
(car (sort list #'<)))
;;finds maximum in a list
(defun maximum (list)
(car (sort list #'>)))
;;calculates the range of a list
(defun range (list)
(- (maximum list) (minimum list)))
;;scales one value to another range
(defun scale-value (list low high n)
(+ (/ (* (- (nth (- n 1) list)
(minimum list))
(- high low))
(range list))
low))
;;is supposed to scale the whole list to another range
(defun scale-list (list low high n)
(unless (= n 0)
(cons (scale-value list low high n)
(scale-list list low high (- n 1)))))
(scale-list '(1 2 3 4) 21 24 4)
【问题讨论】:
-
你的编辑和这个问题有什么关系?
-
也许他认为编辑是个口齿不清的人!
-
没有人...但是因为我真的不知道...我想也许编辑器本身就支持一种模式...反正我只是参与了 common lisp 来帮助一个朋友完成他的任务而且我觉得从第 0 天起我就不必了解该语言的所有知识......所以放轻松
标签: common-lisp scaling slime aquamacs