Hi,

It's friday afternoon (here in Sweden that is) so here's a small script
with goodies from Haskell (functional programming language) for Ruby: 

http://www.ce.chalmers.se/~feldt/ruby/extensions/funcprog/

Right now its only the powerful Haskell list functions added to Enumerable
and Array but LazyArray (infinite sequences) is coming along (its working
but requires changes to MetaRuby so I'll have to talk to Matju before
including it...).

Maybe its too much a feature bloat to add all of them to the built-in
stuff but IMHO the following ones are very useful (and most have been
previously discussed here on ruby-talk): 

        [0,2,4,6,8].all? {|e| e>=0}           # => true
        [10,14,18].any? {|e| e%2 == 1}        # => false
        (0..4).to_a.partition {|e| e%2 == 0}  # => [[0,2,4], [1,3]]
        [1,2,3,4].foldl(:+)                   # => 10
        [1,2,3].scanl(0) {|a,b| a+b})         # => [0,1,3,6]
        [1,2,3,4].zip([10,20,30])             # => [[1,10],[2,20],[3,30]]
        [1,2,3].tail                          # => [2,3]
        [1,2,3,4].init                        # => [1,2,3]

and have'nt you all dreamt of doing quicksort as:

 def qsort(a)
  a[0]?(l,h=a.tail.partition{|e|e<a[0]};(qsort(l)<<a[0])+qsort(h)):a
 end

;-) (and I dont recommend it either but its friday... ;-))

Have a nice weekend!

Regards,

Robert

Ps. Matju: Small changes are needed to ArrayMixin and ListMixin so they
can be used with LazyArrays that may have infinite length. Changes won't
change the semantics or speed of the current implementation; they're
mostly related to comparisons that need to work when one of the numbers is
infinity. If you're interested I can send them!

Pps. hipster had something similar previosly so credits to him.