This seems to be the Haskell equivalent

Tim Matthews tim.matthews7 at gmail.com
Mon Dec 21 15:40:00 PST 2009


On 21/12/2009 8:57 p.m., Don wrote:
> retard wrote:
>> Sun, 20 Dec 2009 16:44:03 +0100, Don wrote:
>>
>>> downs wrote:
>>>> according to
>>>> http://www.mail-archive.com/haskell-cafe%40haskell.org/msg63381.html
>>>>
>>>> I'll let this speak for itself.
>>>>
>>>> import Data.Array.Base (unsafeRead, unsafeWrite)
>>> [snip]
>>>
>>> Brilliant.
>>
>> What is so brilliant? Referential transparency is broken unless single-
>> threadedness is forced through monadic computation or by some other
>> means (uniqueness types comes to mind).
>
> The brilliant bit is the idea of doing a fairer comparison of quicksort
> between D and Haskell.


Quicksort can be expressed in haskell just like this:

qsort []     = []
qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs)


It probably performs like a bitch but is a very beautiful way to express 
quicksort.



More information about the Digitalmars-d mailing list