# New Ticket Created by "Carl Mäsak" # Please include the string: [perl #100464] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=100464 >
<masak> here's another way to implement permutations, courtesy of D. E. Knuth: <masak> nom: sub ix($n) { !$n && [0] || map { [$^a, @^b] }, (0..$n X [ix $n-1]) }; sub perms(@a) { map { my $c = +@a; splice my @p, @^i[--$c], 0, $_ for reverse @a; [@p] }, ix @a-1 }; .join.say for perms <a b c> <p6eval> nom ebd4d8: OUTPUT«Could not find sub &splice [...] <masak> oops. <masak> b: sub ix($n) { !$n && [0] || map { [$^a, @^b] }, (0..$n X [ix $n-1]) }; sub perms(@a) { map { my $c = +@a; splice my @p, @^i[--$c], 0, $_ for reverse @a; [@p] }, ix @a-1 }; .join.say for perms <a b c> <p6eval> b 1b7dd1: OUTPUT«abcacbbaccabbcacba» * masak submits rakudobug about missing 'splice' So, it's a good ol' regression. &splice is missing in nom.