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

14 lines
390 B
Text

templates lexicalPermutations2
def N: $;
[[1]] -> #
when <[<[]($N)>]> do $... !
otherwise
def tails: $;
[1..$tails(1)::length+1 -> \(
def first: $;
$tails... -> [$first, $... -> \(when <$first..> do $+1! otherwise $!\)] !
\)] -> #
end lexicalPermutations2
def alpha: ['ABCD'...];
[ $alpha::length -> lexicalPermutations2 -> '$alpha($)...;' ] -> !OUT::write