Define n functions at once in Lisp -
Suppose I want to do the following:
(from i to 1 to n Loop Apparently I really want to do the following:
(defun 1th (do not define ith (lst) (nth i lst) ) Lst (1 th number) (defun 2th (lst) (nst 2 lst)) (defun 3th (lst) (nth 3 lst)) (defun 4th (lst) (nth 4stst)) ...... < / Code>
Here you should note that | 1 was will return another value: (defmacro make-nths (n) `(old, @ (loop for 1 to n from), as the exchang In the words, > Macrolet < / Code> This may be better here, because you do not really need globally defined macros:
(Macro ((make-nyands (n) `(pregnet, @ For loop) i collect n from 1 (defun, (intern (format zero) ~ at "i" (list) (nth, i list))))))) (make-nths 3)); Finally, here is the working version of the ninja non-macro solution: (Loops for 1 to 3; here select N (each (i () () () () New binding introduction for each frequency (setf (symbol (function zero "~ at" i)); code>
Comments
Post a Comment