"Mike Campbell" <michael_s_campbell / yahoo.com> wrote in message news:<NFBBKBEMGLGCIPPFGHOLMEHOCLAA.michael_s_campbell / yahoo.com>...
> >
> > ISBN_RE.match(self) &&
> > ( (numbers.inject([0]){|x,y| x << (x[-1]+y)}.inject(0){|x,y| x+y}) % 11).zero?
> >
> > martin
> 
> Was the intent here to shorten the code to beyond obfuscation threshholds?
> 
> I thought that was one thing so many on this group rail against perl for...

Nope, just to use two injects rather than an accumulator (which was
what was asked). Which needed the first inject to collect into an
array (since the second inject needed to be passed one).

Besides which, golfing and playing variations on a theme are fun, as
long as you don't mistake the result for maintainable code :)

module Enumerable
  def sum
     #pick your favourite implementation
  end
end

((numbers.inject([0,0]) {|x,y| [x.sum+y, x.pop+y]}.shift) % 11).zero?

martin