Permutations: Difference between revisions

m
→‎{{header|Perl 6}}: itemize returned array so it doesn't flatten in sequence operator; add works with since niecza doesn't do .= reverse yet
(Undo revision 145998, which destroyed the edit button, preventing me from fixing the problem)
m (→‎{{header|Perl 6}}: itemize returned array so it doesn't flatten in sequence operator; add works with since niecza doesn't do .= reverse yet)
Line 1,799:
 
=={{header|Perl 6}}==
{{works with|rakudo|2012-10-24}}
This is generic code that works with any ordered type. To force lexicographic ordering, change <tt>after</tt> to <tt>gt</tt>. To force numeric order, replace it with <tt>&gt;</tt>.
<lang perl6>sub next_perm ( @a is copy ) {
Line 1,812 ⟶ 1,813:
my $s = $j + 1;
@a[ $r--, $s++ ] .= reverse while $r > $s;
return $(@a);
}
 
Anonymous user