2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -5,3 +5,26 @@ fun quicksort [] = []
in
quicksort left @ [x] @ quicksort right
end
------------------------------------------------------------
Solution 2:
Without using List.partition
fun par_helper([], x, l, r) = (l, r) |
par_helper(h::t, x, l, r) =
if h <= x then
par_helper(t, x, l @ [h], r)
else
par_helper(t, x, l, r @ [h]);
fun par(l, x) = par_helper(l, x, [], []);
fun quicksort [] = []
| quicksort (h::t) =
let
val (left, right) = par(t, h)
in
quicksort left @ [h] @ quicksort right
end;