Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,5 @@
|
|||
QuickSort[x_List] := Module[{pivot},
|
||||
If[Length@x <= 1, Return[x]];
|
||||
pivot = RandomChoice@x;
|
||||
Flatten@{QuickSort[Cases[x, j_ /; j < pivot]], Cases[x, j_ /; j == pivot], QuickSort[Cases[x, j_ /; j > pivot]]}
|
||||
]
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
qsort[{}] = {};
|
||||
qsort[{x_, xs___}] := Join[qsort@Select[{xs}, # <= x &], {x}, qsort@Select[{xs}, # > x &]];
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
QuickSort[{}] := {}
|
||||
QuickSort[list: {__}] := With[{pivot=RandomChoice[list]},
|
||||
Join[ <|1->{}, -1->{}|>, GroupBy[list,Order[#,pivot]&] ] // Catenate[ {QuickSort@#[1], #[0], QuickSort@#[-1]} ]&
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue