Data update

This commit is contained in:
Ingy döt Net 2024-03-06 22:25:12 -08:00
parent ed705008a8
commit 0df55f9f24
2196 changed files with 32999 additions and 3075 deletions

View file

@ -3,26 +3,27 @@ templates quicksort
def first: $(1);
def last: $(2);
def pivot: $@quicksort($first);
[ $first + 1, $last ] -> #
@: $(1) + 1;
$(2) -> #
when <?($(2) <..~$(1)>)> do
def limit: $(2);
when <..~$@> do
def limit: $;
@quicksort($first): $@quicksort($limit);
@quicksort($limit): $pivot;
[ $first, $limit - 1 ] !
[ $limit + 1, $last ] !
when <?($@quicksort($(2)) <$pivot~..>)> do
[ $(1), $(2) - 1] -> #
when <?($@quicksort($) <$pivot~..>)> do
$ - 1 -> #
when <?($@quicksort($(1)) <..$pivot>)> do
[ $(1) + 1, $(2)] -> #
when <?($@quicksort($@) <..$pivot>)> do
@: $@ + 1; $ -> #
otherwise
def temp: $@quicksort($(1));
@quicksort($(1)): $@quicksort($(2));
@quicksort($(2)): $temp;
[ $(1) + 1, $(2) - 1] -> #
def temp: $@quicksort($@);
@quicksort($@): $@quicksort($);
@quicksort($): $temp;
@: $@ + 1; $ - 1 -> #
end partial
@: $;
[1, $@::length] -> #