Skip to content

Instantly share code, notes, and snippets.

@hydroid7
Last active November 18, 2019 08:59
Show Gist options
  • Save hydroid7/eeeae7565bed9908fdda62f8034f8c39 to your computer and use it in GitHub Desktop.
Save hydroid7/eeeae7565bed9908fdda62f8034f8c39 to your computer and use it in GitHub Desktop.
The quicksrt algorithm in haskell
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