(* ML examples *)
fun filter f [] = []
| filter f (x::xs) = if f x then x::(filter f xs) else filter f xs
fun append [] ys = ys
| append (x::xs) ys = x::(append xs ys)
fun qsort [] = []
| qsort (p::xs) =
let
val lesser = filter (fn x => x < p) xs
val greater = filter (fn x => x >= p) xs
in
append (qsort lesser) (p::(qsort greater))
end