News for hackers. Stuff that matters.
Re:Ruby is beautiful (but I'm moving to Python) by anthonyb on Monday November 29, 2010 @07:52PM (#1952560)
Well, you need to sort by occurrences, so you have to work with the whole list in this particular case. I also don't think that having two sections is a particularly big deal, since semantically you're working with two separate things too (the list of people+ages, and the aggregated list of names+a count). If you wanted to do something else too (say, list the names as well) then having an intermediate form can come in handy.

Also, I'm pretty sure that writing a macro counts as 'changing the language', although that line's a bit blurred when you're talking about lisps ;) ;)

Re:Ruby is beautiful (but I'm moving to Python) by ataggart on Monday November 29, 2010 @11:13PM (#1953047)
Note, I wasn't criticizing the python implementation. It's a perfectly reasonable way to model the problem.

You brought up list comprehensions, and something about being "blasé about using map". I wanted to show how a different way of modeling the problem yields a different structure to the code (namely, as a chain of transformations on sequences).

One is not better or worse than another. One of the things I enjoyed most about learning clojure was forcing myself to think in these different ways.