This seems to be the Haskell equivalent

Nick Sabalausky a at a.a
Mon Dec 21 16:16:17 PST 2009


"Tim Matthews" <tim.matthews7 at gmail.com> wrote in message 
news:hgp10e$2sj3$1 at digitalmars.com...
> 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.

It's already been pointed out in a number of places that that's not 
quicksort. Quicksort is in-place and doesn't use the head as the pivot. 
Besides "It probably performs like a bitch" defeats the whole point of 
quicksort, doesn't it? And, going along with what Andrei pointed out in 
another thread, it's hard call a piece of code "beautiful" if it's either 
flat-out wrong or otherwise defeats its own point.

This piece of PHP code is "beautiful" too:

$result = doDBQuery("SELECT * FROM $_GET[table]")

...but it's still total shit and therefore worthless.





More information about the Digitalmars-d mailing list