On Sun Dec 23 16:28:31 2012, TimTom wrote:
>
> Rakudo Version: 2012.12-38-gc8de2eb
>
>
> Story:
>
>
> I was attempting to write a different solution to the Collatz Sequence
> problem in this years Advent Calendar. I figured it was a sequence of
> numbers, the sequence operation should be able to rock this problem
> efficiently. I'm not sure if this is supposed to be supported by the
> implementation, but if it is, I believe the problem comes down to
> Rakudo not liking to vivify later elements in the sequence in order to
> vivify the current element.
>
>
> Works:
> my @collatz;
> @collatz := Inf, 1, (2 .. *).map: -> $n {@collatz[$n - 1] + 1}
> say @collatz[0 .. 5]
> > Inf 1 2 3 4 5
>
>
> Doesn't Work:
> my @collatz;
> @collatz := Inf, 1, (2 .. *).map -> $n { $n %% 2 ?? @collatz[$n div 2]
> !! @colatz[3 * $n + 1] }
> say @collatz[0 .. 5]
> splice() not implemented in class 'Mu'
> in method reify at src/gen/CORE.setting:5409
> in method reify at src/gen/CORE.setting:5407
> in method gimme at src/gen/CORE.setting:5797
> in method exists at src/gen/CORE.setting:5786
> in method at_pos at src/gen/CORE.setting:5766
> in method postcircumfix:<[ ]> at src/gen/CORE.setting:1337
> in method postcircumfix:<[ ]> at src/gen/CORE.setting:1384
> in method postcircumfix:<[ ]> at src/gen/CORE.setting:5042
>
>
> -Tim
> irc: Tim-Tom
>
Neither of these work now (2016.07.1)
The first outputs:
(Inf 1 (...) Nil Nil Nil)
And the second
===SORRY!=== Error while compiling /Users/coke/p6
Unexpected block in infix position (missing statement control word before the
expression?)
at /Users/coke/p6:2
------> @collatz := Inf, 1, (2 .. *).map⏏ -> $n { $n %% 2 ?? @collatz[$n div 2]
!
expecting any of:
infix
infix stopper
--
Will "Coke" Coleda