Re: [Haskell-cafe] will the real quicksort please stand up? (or: sorting a > million element list)

2007-11-20 Thread Bertram Felgenhauer
[note, the thread is almost a month old] Bernie Pope wrote: > > On 23/10/2007, at 8:09 AM, Thomas Hartman wrote: >> >> (Prelude sort, which I think is mergesort, just blew the stack.) > > GHC uses a "bottom up" merge sort these days. > > It starts off by creating a list of singletons, then it repe

Re: [Haskell-cafe] will the real quicksort please stand up? (or: sorting a > million element list)

2007-10-24 Thread Brent Yorgey
On 10/23/07, Thomas Hartman <[EMAIL PROTECTED]> wrote: > > > Actually I can't compile it, with or without -O2. loads fine into ghci, > but when I try to create an executable I get > > ghc quicksort.hs -o quicksort > quicksort.o: In function `r1Nc_info': undefined reference to > `QuickCheckzm1zi0zi1

Re: [Haskell-cafe] will the real quicksort please stand up? (or: sorting a > million element list)

2007-10-23 Thread Claus Reinke
It has been noted in a few places that the 2 line quicksort demo in the Introduction section of the haskell wiki http://www.haskell.org/haskellwiki/Introduction isn't a "real" quicksort, and wouldn't scale well with longer lists. Interested, and wanting to put my recently learned test data gener

Re: [Haskell-cafe] will the real quicksort please stand up? (or: sorting a > million element list)

2007-10-23 Thread Bertram Felgenhauer
Bernie Pope wrote: > > On 23/10/2007, at 8:09 AM, Thomas Hartman wrote: >> >> >> (Prelude sort, which I think is mergesort, just blew the stack.) > > GHC uses a "bottom up" merge sort these days. > > It starts off by creating a list of singletons, then it repeatedly merges > adjacent pairs of list

Re: [Haskell-cafe] will the real quicksort please stand up? (or: sorting a > million element list)

2007-10-23 Thread Ketil Malde
[EMAIL PROTECTED] writes: > 1. Avoid two pass filtering. > 2. Avoid unecessary (++), with an accumulator. For example: Also, I find that 3. Accumulate equal elements, too pa (y:ys) s e b = case compare x y of ... to be a good choice. Otherwise, quicksort easily grows towards quadratic i

Re: [Haskell-cafe] will the real quicksort please stand up? (or: sorting a > million element list)

2007-10-22 Thread Bernie Pope
On 23/10/2007, at 8:09 AM, Thomas Hartman wrote: (Prelude sort, which I think is mergesort, just blew the stack.) GHC uses a "bottom up" merge sort these days. It starts off by creating a list of singletons, then it repeatedly merges adjacent pairs of lists until there is only one list l

Re: [Haskell-cafe] will the real quicksort please stand up? (or: sorting a > million element list)

2007-10-22 Thread Brent Yorgey
> I wonder if there are "tricks" or lore that could be applied to get better > results or insight. > > t. Just a quick note, I doubt ghc -e does any optimizations. You'd probably get better results by putting these tests in files and compiling with -O2. In particular I wonder whether that would

Re: [Haskell-cafe] will the real quicksort please stand up? (or: sorting a > million element list)

2007-10-22 Thread jerzy . karczmarczuk
Thomas Hartman writes: another point: "deforested" treesort is slower. The commented indicated that -- If you deforest this algorithm (removing the intermediate tree structure) you are left with treeSort' [] = [] treeSort' (x:xs) = treeSort' (filter (<= x) xs) ++ [x] ++ treeSort' (filter (

Re: [Haskell-cafe] will the real quicksort please stand up? (or: sorting a > million element list)

2007-10-22 Thread Thomas Hartman
another point: "deforested" treesort is slower. [EMAIL PROTECTED]:~/ProjectRepos/learning/quicksort>time ghc -e "test treeSort' 6" quicksort 100 real4m3.615s user1m59.525s sys 0m0.587s The commented indicated that -- If you deforest this algorithm (removing the intermediate tr

[Haskell-cafe] will the real quicksort please stand up? (or: sorting a > million element list)

2007-10-22 Thread Thomas Hartman
It has been noted in a few places that the 2 line quicksort demo in the Introduction section of the haskell wiki http://www.haskell.org/haskellwiki/Introduction isn't a "real" quicksort, and wouldn't scale well with longer lists. Interested, and wanting to put my recently learned test data gen