Created
November 21, 2016 15:03
-
-
Save kaveet/f3601316ce415e16fd4d927a3522cd0c to your computer and use it in GitHub Desktop.
Haskell Selection Sort
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
module SelectionSort where | |
selSort :: (Ord a) => [a] -> [a] | |
selSort [] = [] | |
selSort xs = let x = maximum xs in selSort (remove x xs) ++ [x] | |
where remove _ [] = [] | |
remove a (x:xs) | |
| x == a = xs | |
| otherwise = x : remove a xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment