Page 1 of 1

writing a macro script

Posted: Sun Sep 18, 2011 8:50 pm
by jumperkid400
i am new to lisp and programming in general i have been going through commands as i come upon them while reading structure and interpretation of computer programs. the book is odd and it explains things well but when talking about lisp it doesn't give the actual code for lisp commands. i am trying to write a macro which i am lead to believe will make it so that i can define a list and connect it to a variable rather than typing the entire list over and over.

Code: Select all

> (defmacro lambda-vars 
((lambda (a b c) (+ a b c)) 1 (* 2 3) (- 5 4)) 
'(cadr, ((lambda (a b c) (+ a b c)) 1 (* 2 3) (- 5 4))))
> Error: Reader error on #<CCL::RECORDING-CHARACTER-INPUT-STREAM #x302000F1FFCD>, near position 78:
>        Comma not inside backquote
this is what i get as an error message but when i tried moving the back quote around it didn't accept it. thank you for any help

Re: writing a macro script

Posted: Mon Sep 19, 2011 4:00 am
by ramarren
Structure and Interpretation of Computer Programs is more of a Computer Science book, rather than programming book. To learn programming in Common Lisp you should read something like A Gentle Introduction to Symbolic Computation or Practical Common Lisp.

Re: writing a macro script

Posted: Mon Sep 19, 2011 5:38 pm
by Konfusius
You are using quote instead of backquote. Tbh its impossible to help you because your code doesn't make any sense.