Scrapbook-0.4.0: code examples
Copyright© Frank Jung 2019
LicenseGPL-3
Safe HaskellSafe-Inferred
LanguageHaskell2010

Qsort

Description

A simple implementation of Qsort.

From "Programming in Haskell" by Graham Hutton.

>>> qsort [3,5,1,2,4,2]
[1,2,2,3,4,5]

If a <= x is replaced with a < x, then only unique values are reported.

>>> qsort' [3,5,1,2,4,2]
[1,2,3,4,5]

To reverse sort, switch smaller and larger in qsort.

>>> qsort'' [3,5,1,2,4,2]
[5,4,3,2,2,1]
Synopsis

Documentation

qsort Source #

Arguments

:: (Show a, Ord a) 
=> [a]

list to sort

-> [a]

the sorted list

A simple implementation of Qsort.