Permutations: Difference between revisions
Content added Content deleted
(→{{header|Perl 6}}: adding a simpler, recursive version) |
(→{{header|Perl 6}}: make it behave nice with empty arrays) |
||
Line 1,802: | Line 1,802: | ||
Here is a quick and simple recursive implementation: |
Here is a quick and simple recursive implementation: |
||
<lang Perl6> |
<lang Perl6> |
||
multi postfix:<!>(@a where 1) { [@a] } |
multi postfix:<!>(@a where 0|1) { [@a] } |
||
multi postfix:<!>(@a) { |
multi postfix:<!>(@a) { |
||
gather for @a -> $a { |
gather for @a -> $a { |