writing a macro script

Discussion of Common Lisp

writing a macro script

Postby jumperkid400 » Sun Sep 18, 2011 8:50 pm

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
jumperkid400
 
Posts: 1
Joined: Sun Sep 18, 2011 8:17 pm

Re: writing a macro script

Postby Ramarren » Mon Sep 19, 2011 4:00 am

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.
Ramarren
 
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland

Re: writing a macro script

Postby Konfusius » Mon Sep 19, 2011 5:38 pm

You are using quote instead of backquote. Tbh its impossible to help you because your code doesn't make any sense.
Konfusius
 
Posts: 62
Joined: Fri Jun 10, 2011 6:38 am


Return to Common Lisp

Who is online

Users browsing this forum: Google [Bot] and 4 guests