Function parameters in Lisp.
Hi,
I am using Common Lisp and I wonder how I can pass parameters by address to a Lisp function. As an example I would write something like: (myfuntion v 18) and the value of v would be 18 after calling the function, indepently of what it is before. The function definition would probably look like this: (defun myfuntion(p v) (setf p v)) But my problem is to know the right way to pass the parameters. Thanks for any tip. |
Hello zaxonus,
I don't know if I can help, I'm learning functional programming (lisp and scheme) since some month, but with not too much advancement. Quote:
Quote:
It may be helpful if you describe in a more detailed manner what your program does or should do respectivley. Maybe you'll find more help then. Markus |
Quote:
There is a sense in which lists are already passed by reference. For example, the following will change the first element of the list: Code:
(defun modify (n) (setf (car n) 18)) Code:
(defun modify (n) (set n 18)) Code:
(defun modify (setn) (funcall setn 18)) |
All times are GMT -5. The time now is 07:04 PM. |