Subject: Re: MAPCAR, FUNCALL & APPLY usage
From: rpw3@rpw3.org (Rob Warnock)
Date: Mon, 11 Aug 2003 04:36:15 -0500
Newsgroups: comp.lang.lisp
Message-ID: <XrmdndhOAr8S_qqiXTWc-g@speakeasy.net>
Andreas Fuchs  <asf@void.at> wrote:
+---------------
| Today, Rob Warnock <rpw3@rpw3.org> wrote:
| > Well, let me qualify that: If you do try to implement APPLY in terms
| > of FUNCALL, you end up with the same kind of godawful mess you get
| > when trying to emulate APPLY in C ...
...
| Try this instead:
| 
| (defun apply-definer (max-args)
|   `(defun my-apply (f &rest args)
|      (case (length args)
|        ,@(loop for arg-count from 0 to max-args
| 	   collect `((,arg-count)
| 		     (funcall
| 		      f
| 		      ,@(loop for arg-idx from 0 to (1- arg-count)
| 			   collect `(nth ,arg-idx args)))))
|        (otherwise
| 	(error ,(format nil "Can't apply to more than ~A args" max-args))))))
+---------------

D'oh!! Just when I begin to think I'm finally starting to think in CL,
somebody like you comes along and points out that I really haven't yet
fully internalized "the Lisp way"[1].

Thanks. (No, really!!)


-Rob

[1] Not to be confused with The Lambda Nature, which even Schemers have
    to some extent.

-----
Rob Warnock, PP-ASEL-IA		<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607