Hi, 「gather」 should work. What version of Perl 6 are you using? (run perl6 -v)
I may be wrong, but I think the code should be: my \golden = (1 + sqrt 5) ÷ 2; my \fib = 1, 1, * + * ... ∞ ; my \approx = gather for fib.rotor(2 => -1) { take .[1] ÷ .[0] }; my \distances = approx.map: (golden - *).abs; say distances[^1000]; On 2017-03-13 13:28:24 GMT, Marc Chantreux wrote: > hello, > > i saw a math show with my son and we tried to use perl6 > > * to demonstrate the fact that the ratio between the terms > n and n-1 in the fibonnaci sequence gets closer to the golden number > > * let him know how awesome is perl6 > > so i wrote > > my \golden = ( 1 / sqrt 5 ) / 2; > my \fib = ( 1, 1, * + * ... * ); > my \approx = (gather for fib -> $a, $b { take $a / $b }); > my \distances = approx.map( abs golden - * ); > say [>=] distances[^1000]; > > and it didn't work: i had to rewrite > > my \distances = approx.map( abs golden - * ); > > to > > my \distances = approx.map({ abs golden - $_ }); > > which is not so appealing. > > then my programs starts to burn cpu and gets nothing. this is because it > seems that gather isn't on demand so i moved the subscript [^1000]. this > works but isn't intellectually right anymore. > > any idea to make it more appealing ? > > regards