Andy
Andy

Reputation: 10840

How to send lists as function parameters in lisp?

So I have an error:

EVAL: undefined function P1

Below is my code so far.

(defun andexp (a b) (list 'and a b))
(defun orexp (a b) (list 'or a b))
(defun notexp (a) (list 'not a))

(defun evalexp (main-list bind-list)
;first change the bind-list to work with sublis
(setq new-bind-list (list (car bind-list).(cdr bind-list)))
;here will go the looping to check matching variable names
(sublis main-list new-bind-list)

);end of evalexp function

Here I am creating an expression:

(setq p1 (andexp 1 (orexp 'a 'b)))

Which evaluates to this:

(and 1 (or a b))

when I run the code below, I get the error I mentioned above.

(evalexp ( p1 '( (a 0) (b 1))))

p1 should contain a list, so I assumed it would work. This leads to my question of, how am I suppose to send lists as parameters into a function? Am I doing it wrong, or is it something else?

Upvotes: 1

Views: 341

Answers (1)

Dan D.
Dan D.

Reputation: 74675

note the erroneous extra parens:

(evalexp ( p1 '( (a 0) (b 1))))

should be

(evalexp p1 '((a 0) (b 1)))

Upvotes: 2

Related Questions