Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 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