Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View 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

View 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

View 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

View 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