Lisp Illegal argument in functor position

泄露秘密 提交于 2019-12-12 06:51:46

问题


Hello can anyone help me out?

(defun f(x)
    (LIST ((* 2 x) (* 3 x)))
)

(f 1)

I get this, Illegal argument in functor position: (* 2 X) in ((* 2 X) (* 3 X)).


回答1:


It should be:

(defun f (x)
    (list (* 2 x) (* 3 x)))

You have an extra set of parentheses around the arguments to list. When an expression is a list, the first thing is supposed to be the function to call, so

((* 2 x) (* 3 x))

is not a valid expression because (* 2 x) is not a function.



来源:https://stackoverflow.com/questions/23297834/lisp-illegal-argument-in-functor-position

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!