From: Mike Campbell Date: 2002-10-17T12:20:36+09:00 Subject: Re: Please check my algorithm > dblack@candle.superlink.net wrote in message > news:... > > > Well, for what it's worth, here's my 1.7-only version (it uses > > #inject). I can't help feeling there's a way to do some kind of > > double inject, and avoid using the 't' accumulator... but anyway, here > > is its current incarnation: > > > > t = 0 > > ISBN_RE.match(self) && > > numbers.inject(0) {|x,y| t += x+y; x+y } && > > (t % 11) .zero? > > end > > 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...