RosettaCodeData/Task/Permutations/Tailspin/permutations-7.tailspin
2024-10-16 18:07:41 -07:00

18 lines
454 B
Text

templates perms
templates findPerms
when <$@perms::length..> do $@perms !
otherwise
def index: $;
$index..$@perms::length
-> \(
@perms([$, $index]): $@perms([$index, $])...;
$index + 1 -> findPerms !
\) !
@perms([last, $index..last-1]): $@perms($index..last)...;
end findPerms
@: [1..$];
1 -> findPerms !
end perms
def alpha: ['ABCD'...];
[4 -> perms -> '$alpha($)...;' ] -> !OUT::write