【发布时间】:2012-06-05 20:23:12
【问题描述】:
我在 LISP 中有这个函数,带有常规参数和可选参数 n:
(defun lastplus (x &optional (n 0)) //default value for n is 0
( if (listp x) //if x is a list
(
(list (length x) (n)) //return list that contains length(x) and n
)
(n) //else return n
)
)
我正在尝试使用侦听器文件中的函数,但它给了我这个错误:
CL-USER 13 : 4 > (lastplus 2 8)
Error: Undefined function N called with arguments ().
我使用 LispWorks 6.0.1
你知道我为什么会收到这个错误吗?
【问题讨论】:
-
//是一个有效的令牌。特别是,它没有引入评论。评论用;引入或包含在#||#中。 -
你是对的。我只在我的问题中添加了这些“//”..
-
顺便说一句,'CL-USER 13 : 4 >' 表示您处于调试级别。您可能想回到顶层。使用命令 :top .
标签: function lisp optional-parameters