[Haskell-cafe] Space Efficiency When Sorting a List of Many Lists

2010-01-04 Thread Peter Green
Heinrich, thanks for some great help and food for thought! (More on performance of your solution below) Thanks for describing the background of this problem in detail! I was mainly asking because I'm always looking for interesting Haskell topics that can be turned into a tutorial of sorts,

Re: [Haskell-cafe] Space Efficiency When Sorting a List of Many Lists

2010-01-02 Thread Peter Green
On 31/12/2009, at 6:38 PM, Luke Palmer wrote: On Wed, Dec 30, 2009 at 9:39 PM, Peter Green kinch1...@me.com wrote: I can guess that there might be be less laziness and more instantiation when sorting is introduced, Yes, by a lot. Sorting requires keeping the entire list in memory. And

Re: [Haskell-cafe] Space Efficiency When Sorting a List of Many Lists

2009-12-31 Thread Patai Gergely
Hi, explode [[[1,2],[3],[4,5,6]], [[1, 2], [14,15], [16]]] -- [[1,3,4], [1,3,5],[1,3,6],[2,3,4],[2,3,5],[2,3,6],[1,14,16],[1,15,16], [2,14,16],[2,15,16]] I don't think the following will solve your problem, but explode can be rewritten with existing functions thanks to the list monad:

Re: [Haskell-cafe] Space Efficiency When Sorting a List of Many Lists

2009-12-31 Thread Luke Palmer
On Wed, Dec 30, 2009 at 9:39 PM, Peter Green kinch1...@me.com wrote: I can guess that there might be be less laziness and more instantiation when  sorting is introduced, Yes, by a lot. Sorting requires keeping the entire list in memory. And Haskell lists, unfortunately, are not that cheap in

Re: [Haskell-cafe] Space Efficiency When Sorting a List of Many Lists

2009-12-31 Thread Daniel Fischer
Am Donnerstag 31 Dezember 2009 11:38:51 schrieb Luke Palmer: This cartesian product varies in its tail faster than its head, so every head gets its own unique tail.  If you reverse the order of the bindings so that it varies in its head faster, then tails are shared. If my quick and dirty

Re: [Haskell-cafe] Space Efficiency When Sorting a List of Many Lists

2009-12-31 Thread Felipe Lessa
On Thu, Dec 31, 2009 at 03:38:51AM -0700, Luke Palmer wrote: But if you're serious, you can probably do better than just generating them all and passing them to sort. I get the impression that there is some structure here that can be taken advantage of. Isn't what he wants a trie? In

[Haskell-cafe] Space Efficiency When Sorting a List of Many Lists

2009-12-30 Thread Peter Green
I'm a Haskell neophyte, so may be missing something obvious in the problem outlined below. I'm fairly proficient in Python + have some limited experience in OCaml and F#, so know just enough to be be dangerous, but not nearly enough to really know what I'm doing here. OK, I have text files

Re: [Haskell-cafe] Space Efficiency When Sorting a List of Many Lists

2009-12-30 Thread Alexander Dunlap
On Wed, Dec 30, 2009 at 8:39 PM, Peter Green kinch1...@me.com wrote: I'm a Haskell neophyte, so may be missing something obvious in the problem outlined below. I'm fairly proficient in Python + have some limited experience in OCaml and F#, so know just enough to be be dangerous, but not nearly