diff options
author | Jed Barber <jjbarber@y7mail.com> | 2015-10-14 12:21:23 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2015-10-14 12:21:23 +1100 |
commit | 3e30658ec5ca3ade4f9295129729127a30b4addf (patch) | |
tree | b18666d29be5e71892f07f084a2b96d731358a1e /quicksort.hs | |
parent | e8b414fc52cd70dc0d59a8f182eac1d72e56fa6d (diff) |
Added bubble, quick, selection, merge, gnome sorting algorithms
Diffstat (limited to 'quicksort.hs')
-rw-r--r-- | quicksort.hs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/quicksort.hs b/quicksort.hs new file mode 100644 index 0000000..78330f3 --- /dev/null +++ b/quicksort.hs @@ -0,0 +1,12 @@ + + + +quickSort :: Ord a => [a] -> [a] +quickSort [] = [] +quickSort (x:xs) = + let less = [ a | a <- xs, a < x ] + equal = [ b | b <- (x:xs), b == x ] + greater = [ c | c <- xs, c > x ] + in quickSort less ++ equal ++ quickSort greater + + |