Talk:Haskell/Higher-order functions/Archive 1

In the first listing, where less = filter (< x) xs and below - don't work in my GHCi. Have to write it like this: where less = filter (< x) xs etc.


 * Are you sure? I copied-and-pasted it into h.hs, and did a :load "/home/gwern/h.hs" within GHCi and sure enough:

*Main> quickSort [1,5,8,15,1,3,4] [1,1,3,4,5,8,15]


 * Gwern (contribs) 20:08, 8 February 2007 (UTC)

I was wrong: the trouble was caused by an editor with non-monospace font, so while it seemed that code is well indented, it was, in fact, not. Sorry.

almost completed?
calling Eric: now that this section has the currying section filled up, can you just give it a revision and remove that irriatating 50% completed symbol? — 58.106.132.214, 2008-02-26T10:14:26

I'll at least remove the stub tag. —Toby Bartels (talk) 21:56, 18 November 2008 (UTC)

2014-04-29 refactoring
The case for  is strictly unnecessary. Do we want to omit it? Is it good form to include it in real programs? If so, I say we keep it and explain why it helps. I'm guessing it is more efficient. Despite Haskell's laziness, maybe this is faster than running through the full recursive pattern to verify that a single-element list stays the same. If so, we should explain. If not, maybe we should just remove this extraneous thing. Or maybe it should just be a comment but not be included in the actual example code. Backfromquadrangle (discuss • contribs) 16:52, 29 April 2014 (UTC)


 * I think we should remove it. While it might help performance a little bit, the cute one-liner quicksort we use here is relatively inefficient anyway (three passes through  per step, indiscriminate usage of  ), so there is no need to bother with small optimisations like that one. As for the "this is more explicit" justification in the book, it is far off the mark - adding redundant patterns makes code harder to read. Even in things like , which was written to provide decent performance, you don't find   patterns (the only one in   is a genuine base case in the mergesort implementation).--Duplode (discuss • contribs) 09:09, 30 April 2014 (UTC)


 * I removed those. Backfromquadrangle (discuss • contribs) 18:36, 30 April 2014 (UTC)

Something with the indentation is wrong in the code now, but I'm not sure what the issue is, why it is wrong. Backfromquadrangle (discuss • contribs) 18:16, 29 April 2014 (UTC)


 * Do you have any specific code block in mind? After a quick glance I didn't see anything strange (other than the  clauses indented half a mile to the right for no good reason).--Duplode (discuss • contribs) 09:09, 30 April 2014 (UTC)


 * I adjusted the extreme indentation, but it was the second and third cases under the where were not lining up quite right in my rendering. To fix it, I moved all three cases to separate lines from the where.