Subject: Re: Another FAQ (my brain isn't working)
From: (Rob Warnock)
Date: Fri, 28 Mar 2003 05:59:41 -0600
Newsgroups: comp.lang.lisp
Message-ID: <>
Marco Antoniotti  <> wrote:
|   (defmacro plus (&rest args) `(+ ,@args))
| Now I have a list
|   (defvar *numbers* (list 1 2 3))
| You know the question.  How do I do the equivalent of
|   (apply #'+ *numbers*)

At the cost of losing the efficiency of the macro (assuming
the actual case is much more complex than you've given here),
you could always do:

    (reduce #'(lambda (x y) (plus x y)) *numbers*)

Which brings up a side point: Given that I use the Unix command
"xargs" with some frequency (expecially with the "-n" option),
it's often been frustrating to me that REDUCE doesn't accept a
keyword parameter specifying the maximum number of arguments that
can be passed to its first parameter per call, defaulting to 2.
Then you could portably chunk through *huge* reductions N args
at a time. In the limit (pardon the pun) even saying:

    (reduce #'+ *numbers* :max-args call-arguments-limit)

[Useful for Lisps with values of "call-arguments-limit" close to
the minimums required by the standard.]

Was this considered at all when REDUCE was standardized?


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