RosettaCodeData/Task/Permutations/Tailspin/permutations-2.tailspin
2023-07-01 13:44:08 -04:00

11 lines
346 B
Text

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