Retard
Retard

Reputation: 1

Lisp Illegal argument in functor position

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

Upvotes: -1

Views: 1228

Answers (1)

Barmar
Barmar

Reputation: 782693

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.

Upvotes: 4

Related Questions