in reply to Re^2: fibonacci numbers using subroutine?
in thread fibonacci numbers using subroutine?
Both lists and arrays can be lazily infinite in Perl 6; the only real difference is whether the values are kept in an indexable form as they are generated. Note also that the memoization naturally uses an array rather than a hash in this case, which saves memory over those memoization techniques that must assume a hash for generality.my @fib := (0,1, *+* ... *); say @fib[8]; say @fib[9]; # doesn't recalculate fib(8)
|
---|