Hello, My Hugs tells me this: Prelude> let sort [] = []; sort l@(x:_) = filter (<x) l ++ filter (==x) l ++ filter (>x) l in sort [1,3,2] [1,3,2] Prelude> So, no, this is not a working sorting function. Inserting the "few missing recursive calls": Prelude> let sort [] = []; sort l@(x:_) = sort ( filter (<x) l ) ++ filter (==x) l ++ sort ( filter (>x) l ) in sort [1,3,2] [1,2,3] Prelude> Best regards Thorkil On Friday 13 April 2007 11:38, Thomas Hartman wrote:
And for reference, here is again stefan's "stable" quicksort from his earlier post.
" sort [] = [] sort l@(x:_) = filter (<x) l ++ filter (==x) l ++ filter (>x) l
(A stable quicksort, btw) "
This is the code whose legitimacy I am requesting confirmation of.
2007/4/13, Thomas Hartman <tphyahoo@gmail.com>:
You may be missing a few recursive calls there :-)
Indeed.
...