On Tue Sep 02 08:21:59 2014, coke wrote: > On Mon Jan 30 06:13:36 2012, moritz wrote: > > The code as-is will never work, because at some point it'll pass an > > empty list to one side of the 'merge' operator, in which case the > > subsignature binding fails. > > > > Here is an updated version (see also https://gist.github.com/1704555 > > ) > > > > multi sub infix:<merge> (@ [], @y) is default { @y }; > > multi sub infix:<merge> (@x, @ []) { @x }; > > multi sub infix:<merge> (@x [$x, *@xtail], @y [$y,*@ytail]) { > > if $x < $y { $x, (@xtail merge @y) } > > elsif $x > $y { $y, (@x merge @ytail) } > > else { $x, (@xtail merge @ytail) } > > } > > > > my @hamming := (1, (@hamming X* 2) merge (@hamming X* 3) merge > > (@hamming > > X* 5)); > > > > say ~@hamming[^20]; > > > > output on current rakudo: 1 > > 11:17 < [Coke]> moritz, TimToady: what is the expected output of the > last bit > of code on > https://rt.perl.org/Ticket/Display.html?id=77474 ? > 11:18 < [Coke]> FYI, the current output is 1 0 > 11:19 < TimToady> http://rosettacode.org/wiki/Hamming_numbers > 11:20 < TimToady> but we need the list refactor before that has a hope > of > working > 11:20 < [Coke]> so, "1 2 3 4 5 6 8 9 10 12 15 16 18 20 24 25 27 30 32 > 36" is > the expected output? > 11:21 < TimToady> yes, if Perl 6 were as good as Haskell at recursive > definitions...
Both GLR & NOM now complain that you can't use @hamming to declare @hamming. -- Will "Coke" Coleda
