[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: why tail recursion matters and why Java isn't it, was Re:lisp performance was Re: problems with lisp



At 7:02 PM +0200 9/4/03, Pascal Costanza wrote:
>
>(loop for i in list sum i)
>
>(loop for i in list sum (- i))
>
>However, (apply '+ list) or (apply '- list) are more appropriate in 
>this regard. (In the case of - you get different results, but this 
>is because of the way - is defined.)
>

(reduce #'+ list :initial-value 0) and (reduce #'- list :initial-value 0)
are probably better choices for a "reduction" operation, if I can be a
stickler for detail...