Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,16 @@
|
|||
templates quicksort
|
||||
@: [];
|
||||
$ -> #
|
||||
when <[](2..)> do
|
||||
def pivot: $(1);
|
||||
[ [ $(2..last)... -> \(
|
||||
when <..$pivot> do
|
||||
$ !
|
||||
otherwise
|
||||
..|@quicksort: $;
|
||||
\)] -> quicksort..., $pivot, $@ -> quicksort... ] !
|
||||
otherwise
|
||||
$ !
|
||||
end quicksort
|
||||
|
||||
[4,5,3,8,1,2,6,7,9,8,5] -> quicksort -> !OUT::write
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
templates quicksort
|
||||
templates partial
|
||||
def first: $(1);
|
||||
def last: $(2);
|
||||
def pivot: $@quicksort($first);
|
||||
[ $first + 1, $last ] -> #
|
||||
|
||||
when <?($(2) <..~$(1)>)> do
|
||||
def limit: $(2);
|
||||
@quicksort($first): $@quicksort($limit);
|
||||
@quicksort($limit): $pivot;
|
||||
[ $first, $limit - 1 ] !
|
||||
[ $limit + 1, $last ] !
|
||||
|
||||
when <?($@quicksort($(2)) <$pivot~..>)> do
|
||||
[ $(1), $(2) - 1] -> #
|
||||
|
||||
when <?($@quicksort($(1)) <..$pivot>)> do
|
||||
[ $(1) + 1, $(2)] -> #
|
||||
|
||||
otherwise
|
||||
def temp: $@quicksort($(1));
|
||||
@quicksort($(1)): $@quicksort($(2));
|
||||
@quicksort($(2)): $temp;
|
||||
[ $(1) + 1, $(2) - 1] -> #
|
||||
end partial
|
||||
@: $;
|
||||
[1, $@::length] -> #
|
||||
$@ !
|
||||
|
||||
when <?($(1) <..~$(2)>)> do
|
||||
$ -> partial -> #
|
||||
end quicksort
|
||||
|
||||
[4,5,3,8,1,2,6,7,9,8,5] -> quicksort -> !OUT::write
|
||||
Loading…
Add table
Add a link
Reference in a new issue