This single snippet does not look too obscure to me.
I have the book but never read this part.

>From what I can see, it gets a list of neighbors from the current state in 
>cells,
extract pairs of location/frequency (de structuring loc and n for each pair
returned by frequencies) and returns cells that match the condition (frequency
= 3 or immediate neighbors of frequency 2 of our current state) as a set.
This gives the new state from which to proceed. I can safely assume that
the input state is also a set.

Roughly.... I am vaguely acquainted with the problem to solve. 
Of course having access to the whole source code would help a bit :)

If the above is totally wrong then I need to get back to a coding class...

Luc P.




> 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.
> 
> 
> 
--
Softaddicts<lprefonta...@softaddicts.ca> sent by ibisMail from my ipad!

-- 
-- 
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.


Reply via email to