Last active
December 30, 2020 10:01
-
-
Save devansh42/db29875f104f7f8b278748e793e7c068 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
bubbleSort::(Ord a) => [a] -> [a] | |
bubbleSort [] = [] | |
bubbleSort ([a]) = [a] -- One element array | |
bubbleSort ([a,b]) = if a<b then [a,b] else [b,a] | |
bubbleSort (a:b:bs) = let res = if a < b then [a] ++ bubbleSort([b]++bs) else [b] ++ bubbleSort([a]++bs) in bubbleSort (init res) ++ [last res] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment