From: Louis J Scoras Date: 2005-10-20T04:22:48+09:00 Subject: Re: Functional with Ruby ------=_Part_11943_11484265.1129749762292 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline > But inject *is* functional! It's equivalent to Lisp's accumulate. It > doesn't modify the list at all or have any side-effects. Exactly. Incidentally, the original example isn't really the best way to do this in Haskell either. I haven't written any Haskell for a while, so some of this might not be syntactically correct, but you get the idea. Please correct me if any of this is wrong. The above would best be expressed something like this (Iike I said, it's been a while, so the parameter order might be wrong): foldr + 0 list foldr does exactly the same thing as inject. It takes a binary function, a starting value, and a list. The neat thing about Haskell is that the addition operator--actually any function--is automatically curried. I'd make the claim here that the use of the higher order function is actually better functional style than the explicit recursion. If I recall correctly, many of the list functions in the Hugs standard library are actually implemented this manner. ------=_Part_11943_11484265.1129749762292--