Name:
Anonymous
2016-10-23 8:03
quicksort [] = []
quicksort (x:xs) = quicksort small ++ (x : quicksort large)
where small = [y | y <- xs, y <= x]
large = [y | y <- xs, y > x]
Name:
Anonymous
2016-10-23 16:56
splitTwo :: [a] -> ([a], [a])
splitTwo [] = ([], [])
splitTwo [x] = ([x], [])
splitTwo (x:x':xs) = (x:l, x':r)
where
(l, r) = splitTwo xs
mergeSort :: (Ord a) => [a] -> [a]
mergeSort [] = []
mergeSort [x] = [x]
mergeSort xs = merge (mergeSort l) (mergeSort r)
where
(l, r) = splitTwo xs
merge xss [] = xss
merge [] yss = yss
merge xss@(x:xs) yss@(y:ys)
| x <= y = x : merge xs yss
| otherwise = y : merge xss ys
>>5There are so many ghc extensions I can't see the entire line in browser oh god