メモ:なるほど〜

Ruby1.8

cache = { 0 => 0, 1 => 1 }
fib = lambda {_fib_ = lambda {|n| cache[n] ||= _fib_[n-2] + _fib_[n-1]}}.call
puts (1..20).map(&fib).join(", ")

Ruby1.9

cache = { 0 => 0, 1 => 1}
fib = -> { _fib_ = -> n { cache[n] ||= _fib_[n-2] + _fib_[n-1] } }.call
puts (1..20).map(&fib).join(", ")