Lisp函子位置中的非法论点 [英] Lisp Illegal argument in functor position

查看:76
本文介绍了Lisp函子位置中的非法论点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,有人可以帮我吗?

Hello can anyone help me out?

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

(f 1)

我明白了,Illegal argument in functor position: (* 2 X) in ((* 2 X) (* 3 X)).

推荐答案

应为:

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

对于list的参数,您还有一组括号.当表达式是列表时,第一件事应该是要调用的函数,所以

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))

不是有效的表达式,因为(* 2 x)不是函数.

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

这篇关于Lisp函子位置中的非法论点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆