I'm sorry but that's not true. The version over the page hasn't been re-factored 'into a nicer version' it's been re-factored into a more generic version to support, for example, hexagonal grids.
On Saturday, 13 April 2013 23:12:59 UTC+1, Tj Gabbour wrote: > > Hi, > > The text explains the "elegant" aspects of it; and then in the next page, > they refactor it into a nicer version which was 40% docstring. [1] > > So this is like critiquing the readability of someone's first draft. :) > > > All the best, > Tj > > [1] > https://github.com/clojurebook/ClojureProgramming/blob/7521bcfb52cdf7e598bca3c4e7860d795a67992c/ch03-game-of-life/src/com/clojurebook/collections/life.clj#L122 > > > On Wednesday, April 10, 2013 7:27:58 PM UTC+2, edw...@kenworthy.infowrote: >> >> So, page 143 of Clojure Programming has an implementation of Conway's >> Life: >> >> (defn step >> "Yields the next state of the world" >> [cells] >> (set (for [[loc n] (frequencies (mapcat neighbours cells)) >> >> :when (or (= n 3) (and (= n 2) (cells loc)))] >> >> loc))) >> >> The book claims this to be "an elegant implementation'. >> >> Now it's been a long while since I wrote code to put food on the table - >> but back then if I saw C or C++ code written like this I would describe it >> as obfuscated - the sort of thing I would expect to see in the (now >> defunct?) annual obfuscated C competition. It's concise and rather clever, >> certainly, but hardly self-documenting: it's not very clear what it's doing >> at all- with a couple of magic numbers thrown in for good measure. Rather >> arcane in fact. >> >> Is it just me? Is this considered to be good Clojure code and I'm just >> hopelessly out of touch and need to get with the programme? >> >> >> >> >> -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.