Project

General

Profile

Bug #1613 » closure_segfault.rb

RobertDober (Robert Dober), 06/12/2009 09:20 AM

 
#!/usr/local/bin/ruby -w
# encoding: utf-8
# file: /home/robert/log/ruby/tmp/closure_segfault.rb

module Closing
cache = [1, 1]
define_method :fibo do | n |
return cache[n] if cache[n]
(fibo( n.pred ) + fibo( n.pred.pred )).tap do | result |
cache[ n ] = result
end
end
end
include Closing
puts fibo( 42 * 42 * 5 )

# vim: sts=2 sw=2 ft=ruby expandtab nu :
(1-1/2)