Last active
November 18, 2019 08:59
-
-
Save hydroid7/eeeae7565bed9908fdda62f8034f8c39 to your computer and use it in GitHub Desktop.
The quicksrt algorithm in haskell
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 Sorting (main) where | |
quicksort :: [Integer] -> [Integer] | |
quicksort [] = [] | |
quicksort (x:xs) = quicksort smaller ++ [x] ++ larger | |
where | |
smaller = [a | a <- xs, a <= x] | |
larger = [b | b <- xs, b > x] | |
main = do | |
print(quicksort [1, 2, 3]) | |
print (quicksort [3, 2, 1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment