Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
14
Task/Permutations/Tailspin/permutations-1.tailspin
Normal file
14
Task/Permutations/Tailspin/permutations-1.tailspin
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
templates permutations
|
||||
when <=1> do [1] !
|
||||
otherwise
|
||||
def n: $;
|
||||
templates expand
|
||||
def p: $;
|
||||
1..$n -> \(def k: $;
|
||||
[$p(1..$k-1)..., $n, $p($k..last)...] !\) !
|
||||
end expand
|
||||
$n - 1 -> permutations -> expand !
|
||||
end permutations
|
||||
|
||||
def alpha: ['ABCD'...];
|
||||
[ $alpha::length -> permutations -> '$alpha($)...;' ] -> !OUT::write
|
||||
11
Task/Permutations/Tailspin/permutations-2.tailspin
Normal file
11
Task/Permutations/Tailspin/permutations-2.tailspin
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
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
|
||||
14
Task/Permutations/Tailspin/permutations-3.tailspin
Normal file
14
Task/Permutations/Tailspin/permutations-3.tailspin
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
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
|
||||
18
Task/Permutations/Tailspin/permutations-4.tailspin
Normal file
18
Task/Permutations/Tailspin/permutations-4.tailspin
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue