diff options
author | Yale AI Dept <ai@nebula.cs.yale.edu> | 1993-07-14 13:08:00 -0500 |
---|---|---|
committer | Duncan McGreggor <duncan.mcgreggor@rackspace.com> | 1993-07-14 13:08:00 -0500 |
commit | 4e987026148fe65c323afbc93cd560c07bf06b3f (patch) | |
tree | 26ae54177389edcbe453d25a00c38c2774e8b7d4 /progs/demo/quicksort.hs |
Import to github.
Diffstat (limited to 'progs/demo/quicksort.hs')
-rw-r--r-- | progs/demo/quicksort.hs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/progs/demo/quicksort.hs b/progs/demo/quicksort.hs new file mode 100644 index 0000000..30b4ab4 --- /dev/null +++ b/progs/demo/quicksort.hs @@ -0,0 +1,13 @@ +-- Quick sort for Haskell. + +module Main where + +qs :: [Int] -> [Int] +qs [] = [] +qs (a:as) = qs [x | x <- as, x <= a] ++ [a] ++ qs [x | x <- as, x > a] + +main = + appendChan stdout "Enter a list of integers separated by \",\"\n" abort $ + readChan stdin abort $ \ input -> + appendChan stdout (show (qs (read ("[" ++ (head (lines input)) ++ "]")))) + abort done |