[Haskell-cafe] Quick Sort Algorithm
Malcolm Wallace
Malcolm.Wallace at cs.york.ac.uk
Fri May 18 09:35:59 EDT 2007
PR Stanley <prstanley at ntlworld.com> wrote:
> No, Mr. smarty pants, I can't. I'll leave you to work out why I rely
> on a scanner and an OCR engine for reading printed materials. *smile*
Ah. Well, given your original question ("why does this code not work?")
it was probably a reasonable assumption that you had written it
yourself, and the problem you wanted help with was understanding the
semantics of what you had written. Whereas if you had phrased your
question initially more like "I am having difficulty reading/using this
OCR'd version of someone else's code", the responses could perhaps have
been more helpful more quickly.
Anyway, the corrected code snippet follows:
qSort (x:xs) =
qSort smaller ++ [x] ++ qSort larger
where
smaller = [a | a <- xs, a <= x ]
larger = [b | b <- xs, b > x ]
If your reading software can be trained to convert sequences of symbols
into phrases, then "++" might be pronounced as "append", and "<-" as
"drawn from".
Regards,
Malcolm
More information about the Haskell-Cafe
mailing list