RosettaCodeData/Task/Permutations/Tailspin/permutations-3.tailspin

12 lines
346 B
Plaintext

templates lexicalPermutations
when <=1> do [1] !
otherwise
def n: $;
def p: [ $n - 1 -> lexicalPermutations ];
1..$n -> \(def k: $;
$p... -> [ $k, $... -> \(when <$k..> do $+1! otherwise $!\)] !\) !
end lexicalPermutations
def alpha: ['ABCD'...];
[ $alpha::length -> lexicalPermutations -> '$alpha($)...;' ] -> !OUT::write