qsort [] = []
qsort (x:xs) = qsort lt ++ [x] ++ qsort gt
where
(lt, gt) = partition' (\a -> a <= x) xs
partition' _ [] = ([], [])
partition' f (x:xs)
| f x = ((x:accepted), rejected)
| otherwise = (accepted, (x:rejected))
where (accepted, rejected) = partition' f xs
main = do
print $ qsort [3,4,1,2]
print $ partition' odd [1,2,3,4]
To embed this project on your website, copy the following code and paste it into your website's HTML: