3 ms·
As the post notes a read macro is not a kind of macro. Nevertheless his example is in competition with a macro based approach to the problem. One might wish for
by alan-crowe 16y ago
As the post notes a read macro is not a kind of macro. Nevertheless his example is in competition with a macro based approach to the problem. One might wish for a variant on DEFUN say DEFVN so that one can say
(defvn square (x)
(* x x))
and get both (square 3) => 9 and (square #(1 2 3)) => #(1 4 9). This is not hard; to show off the short paste at http://paste.lisp.org/+24PP http://paste.lisp.org/+24PP one needs a fancier example
(defvn times (&rest v)
(reduce #'* v))
lets (times 2 3 5) => 30, (times #(2 3) 5) => #(10 15), and (times #(1 10 100) 2 #(3 5 7) 0.1) => #(0.6 10.0 140.0)