On Mon, 12 Jul 2004 07:47:12 +0900, Gavin Sinclair
<gsinclair / soyabean.com.au> wrote:
> 'foldl' is, I believe, the same as Enumeration#inject.  Try checking
> out the docs for that, but:
> 
>   (1..100).inject(0) { |acc,x| acc + x }

Wow, I didn't know about Enumerable#inject. Semantically, it's not
quite the same as foldl: for instance, it doesn't make sense to foldl
(or foldr) a Hash, since you're not guaranteed any order. Practically
speaking, however, it's much nicer, since I can use it with Range.

As an aside: It would be nice to have a subclass of Enumerable that
guarantees item order; Array, Range, et al could mix it in.

> For more of these, check out
> 
>    www.rubygarden.org/ruby?StandardClassExtentions
> 
> Some of those, and others besides, are coded up in the 'extensions'
> project on RubyForge, for which I'll gratefully receive suggestions.

Cool, thanks!

Sam