all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,28 @@
|
|||
fn quickSort arr =
|
||||
(
|
||||
less = #()
|
||||
pivotList = #()
|
||||
more = #()
|
||||
if arr.count <= 1 then
|
||||
(
|
||||
arr
|
||||
)
|
||||
else
|
||||
(
|
||||
pivot = arr[arr.count/2]
|
||||
for i in arr do
|
||||
(
|
||||
case of
|
||||
(
|
||||
(i < pivot): (append less i)
|
||||
(i == pivot): (append pivotList i)
|
||||
(i > pivot): (append more i)
|
||||
)
|
||||
)
|
||||
less = quickSort less
|
||||
more = quickSort more
|
||||
less + pivotList + more
|
||||
)
|
||||
)
|
||||
a = #(4, 89, -3, 42, 5, 0, 2, 889)
|
||||
a = quickSort a
|
||||
Loading…
Add table
Add a link
Reference in a new issue