Skip to content

Instantly share code, notes, and snippets.

@moritz
Created January 30, 2012 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moritz/1704555 to your computer and use it in GitHub Desktop.
Save moritz/1704555 to your computer and use it in GitHub Desktop.
RT #77474
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];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment