Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
|
|
@ -0,0 +1,12 @@
|
|||
fun quickselect (_, _, []) = raise Fail "empty"
|
||||
| quickselect (k, cmp, x :: xs) = let
|
||||
val (ys, zs) = List.partition (fn y => cmp (y, x) = LESS) xs
|
||||
val l = length ys
|
||||
in
|
||||
if k < l then
|
||||
quickselect (k, cmp, ys)
|
||||
else if k > l then
|
||||
quickselect (k-l-1, cmp, zs)
|
||||
else
|
||||
x
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue