in reply to Re^4: How will you use state declared variables in Perl6?
in thread How will you use state declared variables in Perl6?
You must be running an older pugs. In fact, the current (working) version in the pugs repository (r14657) now reads:
It would also work as state @seen = 0,1,1 except there's a bug with initializing state variables using a list that causes it to reinitialize every time instead of just the first time, which, while it lets it run, kinda defeats the memoization...sub fib (UInt $n) { (state $seen = [0,1,1]).[$n] //= fib($n-1) + fib($n-2); }
|
---|
In Section
Meditations