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

17 lines
341 B
Text
Raw Permalink Normal View History

2024-10-16 18:07:41 -07:00
permutations templates
when <|=1> do [1] !
2023-07-01 11:58:00 -04:00
otherwise
2024-10-16 18:07:41 -07:00
n is $;
expand templates
p is $;
1..$n -> templates
k is $;
[$p(..$k - 1)..., $n, $p($k..)...] !
end !
end expand
$n - 1 -> # -> expand !
end permutations
2023-07-01 11:58:00 -04:00
2024-10-16 18:07:41 -07:00
alpha is ['ABCD'...];
[ $alpha::length -> permutations -> '$alpha($)...;' ] !