15 lines
351 B
Plaintext
15 lines
351 B
Plaintext
templates permutations
|
|
when <=1> do [1] !
|
|
otherwise
|
|
def n: $;
|
|
templates expand
|
|
def p: $;
|
|
1..$n -> \(def k: $;
|
|
[$p(1..$k-1)..., $n, $p($k..last)...] !\) !
|
|
end expand
|
|
$n - 1 -> permutations -> expand !
|
|
end permutations
|
|
|
|
def alpha: ['ABCD'...];
|
|
[ $alpha::length -> permutations -> '$alpha($)...;' ] -> !OUT::write
|