4 ms·
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 particu
by anthonyb 16y ago
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 ;) ;)
- ataggart 16y agoNote, 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.