I didn't read it carefully here, as I had already seen the presentation and it wasn't until your disagreement I realized the code was different.
I didn't read it carefully here, as I had already seen the presentation and it wasn't until your disagreement I realized the code was different.
There's nothing wrong with if/elses, but I strongly prefer pattern matching, where available. And even more, I think it's important to keep computation and presentation separate... that is, to not entagle IO with the rest of the code.
(Unfortunately Haskell is the only language I know of that gives you a tool to tackle that)
Obviously this was just a small example, but I've seen unintended IO byte back the developer in real world (Python) code.
And another small comment: since I haven't bothered to comment on Hettinger's talk before now.
I liked it (but played it back at 1.5x)... but since it's not first talk by Raymond Hettinger I saw, I knew that his delivery is good. Some of the stuff (should?) be obvious to every (Python) developer (but repetita juvant). I didn't like the jab at Java for the mistake of iterating over indexes: there's no excuse to writing that code not even there (look at the Iterator and Iterable interfaces)