News for hackers. Stuff that matters.
Re:Why isn't Haskell popular in industry? by Flow on Monday August 02, 2010 @04:53AM (#1567194)
You mean max = last . sort ?
Re:Why isn't Haskell popular in industry? by loewenskind on Monday August 02, 2010 @05:18AM (#1567227)
No, using head is what causes the result to be O(n) even though sorting should be more complex. By only using the first entry, only the first entry will actually be found by the sort.

I assume you're pointing out that I have my sort backwards but I was being intentionally as ambiguous with this part because it's not relevant to the point I was making.

Re:Why isn't Haskell popular in industry? by Flow on Monday August 02, 2010 @06:17AM (#1567302)
I understand that lazyness could make it only sort as much as needed to get the first element in the sorted list.

Yes, it's triggers my Rainman instincts to point out that 1. It should be max = last . sort 2. Or min = head . sort 3. You are making assumptions on the sorting algorithm to make it possible to short-cut the evaluation.

K-MART! K-MART! :)

Edit: How nice of you to downvote...

Re:Why isn't Haskell popular in industry? by loewenskind on Monday August 02, 2010 @08:11AM (#1567427)
It wasn't me who downvoted. I can't (since you responded to me) and wouldn't have anyway. If you use last then that means the whole list will have to be sorted O(n log n ish) then the last element retrieved. And yes, I'm assuming a merge sort. But I still don't think that detracts too much from my point.
Re:Why isn't Haskell popular in industry? by Flow on Monday August 02, 2010 @09:16PM (#1569738)
Could you please s/max/min/ in your first post?
Re:Why isn't Haskell popular in industry? by loewenskind on Tuesday August 03, 2010 @03:20AM (#1570420)
But it depends on the sort algorithm. In the exercise I did this on (in Ocaml with some custom lazy code, since Ocaml's wasn't lazy enough for what I was doing) I did sort in descending order.
Re:Why isn't Haskell popular in industry? by Flow on Tuesday August 03, 2010 @05:12AM (#1570593)
Are you saying you made a sort function that sorts reversed, and named it sort? What's wrong with sortDesc?

I think you should be more careful with following conventions. Everyone knows sort sorts ascending.

Re:Why isn't Haskell popular in industry? by loewenskind on Tuesday August 03, 2010 @09:53AM (#1571093)
Conceded. But I can't edit my original comment now. :(