2 ms·
;;; The Daily WTF to the rescue, no eval or introspection needed (defun my-apply (f lst) (case (length lst) (0 (funcall f)) (1 (funca
by GregBuchholz 12y ago
;;; The Daily WTF to the rescue, no eval or introspection needed
(defun my-apply (f lst)
(case (length lst)
(0 (funcall f))
(1 (funcall f (nth 0 lst)))
(2 (funcall f (nth 0 lst) (nth 1 lst)))
(3 (funcall f (nth 0 lst) (nth 1 lst) (nth 2 lst)))
(t 'YouNeedToExtendThisInTheObviousWay)))
...IIRC Common Lisp allows your implementation to limit the number of arguments a function can take.
http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/convar_call-a_uments-limit.html http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec...