|
|
|
|
|
by hristov
5663 days ago
|
|
Ok, I am still learning Haskell, but I thought I would try to fix the above so that there is only one filter pass: qsort :: Ord a => [a] -> [a]
qsort [] = []
qsort [x] = [x]
qsort (p:xs) = qsort lesser ++ [p] ++ qsort greater
where
(lesser, greater) = foldl split ([],[]) xs
where
split (left, right) x = if x<p then (left:x, right), else (left, right:x)
Does this work? |
|