Created
August 9, 2014 15:27
-
-
Save Ikke/2fa9f39ca1459ebf87ec to your computer and use it in GitHub Desktop.
This file contains hidden or 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
bubblesort :: (Ord a) => [a] -> [a] | |
bubblesort [] = [] | |
bubblesort (x1:x2:xs) = | |
let sorted = if x2 < x1 | |
then x2 : bubblesort (x1:xs) | |
else x1 : bubblesort (x2:xs) | |
in (bubblesort $ init sorted) ++ [last sorted] | |
bubblesort xs = xs | |
main = do | |
let foo = bubblesort [5,2,4,8,1,3,7] | |
print foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment