let rec partition f = function
| [] -> [], []
| x::xs ->
let ys, zs = partition f xs in
if f x
then x::ys, zs
else ys, x::zs
let rec qsort = function
| [] -> []
| p::xs ->
let ys, zs = partition (fun x -> x <= p) xs in
qsort ys @ [p] @ qsort zs
let li = [5;1;4;2;3;0]
let sorted = qsort li
let odds_evens = partition (fun x -> x % 2 = 1) sorted
printfn "%A" sorted
printfn "%A" odds_evens
To embed this project on your website, copy the following code and paste it into your website's HTML: