[ create a new paste ] login | about

Link: http://codepad.org/ycOo7Z12    [ raw code | output | fork ]

johannes - Haskell, pasted on Jan 13:
1
2
3
4
5
6
7
8
9
10
11
module Main where

qs :: Ord a => [a] -> [a]
qs [] = []
qs (pivot:xs) = qs lhs ++ pivot : qs rhs
  where
    lhs = filter (< pivot) xs
    rhs = filter (> pivot) xs

main :: IO ()
main = print $ qs [3, 6, 12, 10, 5, 11, 14, 4, 13, 9, 2, 1, 7, 16, 8, 15]


Output:
1
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]


Create a new paste based on this one


Comments: