Hacker News new | past | comments | ask | show | jobs | submit login

I don't think the point is the implementation itself, just what the author finds interesting in a problem. After all the 'plus' operator just does a series of ordered comparisons like the minBy solution does.



Sure. However, it does represent problems I've seen before with "overly" (subject to the person, I guess) complex solutions that end up being significantly less efficient. In this case, the problem is actually the `.toSet`, which forces a second iteration of the dataset. If the Monoid class was rewritten (yes, to be less mathematically pure) to use Seqs, it's nearly identical performance (as expected) as the linear solution.

Fun performance graph: http://i.imgur.com/2rOvb6V.png


That is interesting. Personally I didn't find framing the original problem as monoid enlightening at all, but that's what I thought the author was getting at.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: