Subject: Re: Why Scheme?
From: (Rob Warnock)
Date: 1999/11/20
Newsgroups: comp.lang.scheme
Message-ID: <8175pp$>
Antonio Leitao  <> wrote:
| I don't know the Scheme limits but, in CommonLisp, there's a limit on
| the number of arguments that a function must accept.  From CLTL2, the
| minimum acceptable is 50 (I don't have here the ANSI spec).
| OTOH, we can use fold (from SRFI1) to achieve the same effect:
| (define (mysum nums) (fold + 0 nums))

On the third hand[*], Common Lisp has "reduce", which does the same thing
as "fold" -- except "reduce" has more optional knobs you can turn for the
edge cases. In the case above, though, it's even simpler than "fold":

	(reduce #'+ nums)

or, if you insist on providing an initial result value (even though one
isn't needed in this case):

	(reduce #'+ nums :initial-value 0)


[*] Tip o' the hat to Larry Niven & Jerry Pournelle

Rob Warnock, 8L-846
Applied Networking
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		FAX: 650-933-0511
Mountain View, CA  94043	PP-ASEL-IA