Sam Stephenson <sstephenson / gmail.com> wrote:
> There's a few trivial but useful "extensions" to Ruby's standard
> library that I find myself using in most of my projects. I'll share a
> couple, and I'd really love to see what you're using, too.

I've found this useful on several occasions

class Array
  include EnumerableOperator
  def all_pairs
    a = size-1
    for i,j in product(0..a, 0..a, proc {|i,j| i < j})
      yield at(i), at(j)
    end
  end
end

It depends on http://zem.novylen.net/ruby/fproduct.rb

Called all_pairs to distinguish it from the [1,2] [2,3] [3,4]... meaning
of each_pair

martin