Closed nbezzala closed 10 years ago
I used this code:
sub gen_fib { my @fibs = (0, 1); return sub { my $item = shift; if ( $item >= @fibs ) { for my $calc (@fibs .. $item ) { $fibs[$calc] = $fibs[$calc - 2] + $fibs[$calc - 1]; } } return $fibs[$item]; } } say gen_fib(5);
And I got this as the result: CODE(0x3f9bf4)
Maybe it would help to add a couple of lines like this:
my $func = gen_fib(); say $func->(15);
Fixed in f4f96f4. Thanks for the report!
I used this code:
And I got this as the result: CODE(0x3f9bf4)