Last active
March 9, 2018 02:18
-
-
Save KirinDave/3d88cffcb1f7a9f6b9f9b4d9d5e2eb96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mergeSort :: Ord a => [a] -> [a] | |
mergeSort = hylo alg coalg where | |
alg EmptyF = [] | |
alg (LeafF c) = [c] | |
alg (NodeF l r) = merge l r | |
coalg [] = EmptyF | |
coalg [x] = LeafF x | |
coalg xs = NodeF l r where | |
(l, r) = splitAt (length xs `div` 2) xs | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment