That said the code probably only needs a couple meaningfully-named private functions to help make it more immediately obvious what it is doing, imo.
On Wed, Apr 10, 2013 at 10:39 AM, Alex Baranosky < alexander.barano...@gmail.com> wrote: > It isn't just you. It is not easy for me to see how this code works, > until I think about it for a while. In code review that'd be my main > concern. > > No offense to the author, because the implementation is actually really > neat. :) > > > On Wed, Apr 10, 2013 at 10:27 AM, <edw...@kenworthy.info> wrote: > >> 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. >> >> >> > > -- -- 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.