Hello,
My nick is Methusala and I am a recovering Javaholic.
I would like to be able to turn a function into a list at the repl, so I can experiment with meta programming in the REPL. I know how to use a list like a function:
CL-USER> (setf g '(+ 2 2))
(+ 2 2)
CL-USER> g
(+ 2 2)
CL-USER> (eval g)
4
But how do you use a function like a list?
Here is my current best guess, which doesn't output a list, but does at least show the functions code:
CL-USER> (defun h (x) (+ x x))
H
CL-USER> (h 2)
4
CL-USER> (symbol-function 'h)
#<CLOSURE H (X) (DECLARE (SYSTEM::IN-DEFUN H)) (BLOCK H (+ X X))>
CL-USER> (car (symbol-function 'h))
-causes backtrace.
What should I use instead of symbol-function to get the above to return the car of a list?
Thanx
My nick is Methusala and I am a recovering Javaholic.
I would like to be able to turn a function into a list at the repl, so I can experiment with meta programming in the REPL. I know how to use a list like a function:
CL-USER> (setf g '(+ 2 2))
(+ 2 2)
CL-USER> g
(+ 2 2)
CL-USER> (eval g)
4
But how do you use a function like a list?
Here is my current best guess, which doesn't output a list, but does at least show the functions code:
CL-USER> (defun h (x) (+ x x))
H
CL-USER> (h 2)
4
CL-USER> (symbol-function 'h)
#<CLOSURE H (X) (DECLARE (SYSTEM::IN-DEFUN H)) (BLOCK H (+ X X))>
CL-USER> (car (symbol-function 'h))
-causes backtrace.
What should I use instead of symbol-function to get the above to return the car of a list?
Thanx