- Dec 15, 2003
- 540
- 0
- 0
first of all, yes i know this is the wrong forum, but this gets most traffic and i know there are CS guys out here, so let me just try to squeeze this question in real quick
im trying to write a macro that takes 0 or more variables and sets them all to 0 (in lisp its for hwk)
the only thing i can think of that to do that can take a variable number of arguments is to use &rest , which actually creates a list of the rest of the arguments taken. problem is that when i try to take car of the list, and change the value to 0, it doesnt actually do so
i believe this is an instance of this
i.e.
(setf x 2 y 3 z 4)
(setf a (list x y z)) -> now a = (2 3 4)
(setf (car a) 0)
it doesnt change x to 0, but it does change a -> (0 3 4) as opposed to (2 3 4)
since taking the arguments as a list wont cut it, what other way is there to take a variable number of arguments for a macro??
i can easily write a macro that takes a fixed number of arguments and convert its values to 0, but i just cant figure out how to do it when the number of variables passed is not set.
open to any tips and suggestion on solving this macro problem, thx
im trying to write a macro that takes 0 or more variables and sets them all to 0 (in lisp its for hwk)
the only thing i can think of that to do that can take a variable number of arguments is to use &rest , which actually creates a list of the rest of the arguments taken. problem is that when i try to take car of the list, and change the value to 0, it doesnt actually do so
i believe this is an instance of this
i.e.
(setf x 2 y 3 z 4)
(setf a (list x y z)) -> now a = (2 3 4)
(setf (car a) 0)
it doesnt change x to 0, but it does change a -> (0 3 4) as opposed to (2 3 4)
since taking the arguments as a list wont cut it, what other way is there to take a variable number of arguments for a macro??
i can easily write a macro that takes a fixed number of arguments and convert its values to 0, but i just cant figure out how to do it when the number of variables passed is not set.
open to any tips and suggestion on solving this macro problem, thx