On Feb 12, 10:29 am, James Edward Gray II <j... / grayproductions.net>
wrote:
> On Feb 12, 2007, at 12:00 AM, Phrogz wrote:
> > > Hash.new{|h, n| n==1 ? [1] : [n] + h[n%2 == 0 ? n/2 : n*3+1] }[quiz]
> > Kudos on the memoizing wondrous number, btw. :)
>
> It's not actually.  I never assign the Hash value.  ;)

Interesting point. (And, of course, it wouldn't be useful if it
memoized the result for a single call to the function.) I think it's
interesting because this pattern really allows you to (ab)use the
block form of Hash as a lambda that passes a reference to itself as
one of its arguments. Very convenient for one-liners.