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

12 lines
346 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
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