Re: Neighbors function from The Joy of Clojure

2014-11-05 Thread Mark Nutter
​Forgot to add that my usual recommendation is Clojure in Action followed by The Joy of Clojure. Killer combo.​ On Wed, Nov 5, 2014 at 7:34 AM, Mark Nutter wrote: > A bit off the original topic, but this seemed like a good place to give a > shout out to my favorite intro book: Clojure In Action

Re: Neighbors function from The Joy of Clojure

2014-11-05 Thread Mark Nutter
A bit off the original topic, but this seemed like a good place to give a shout out to my favorite intro book: Clojure In Action ( http://www.manning.com/rathore/). There are a lot of really excellent intro books out there, and I don't want to disparage any of them, but I found this one very readab

Re: Neighbors function from The Joy of Clojure

2014-11-05 Thread Gary Verhaegen
On Wednesday, 5 November 2014, Pierre Thibault wrote: > Ouch! I found this code hard to understand. I read to previous part of the > book. I guess it is normal when you are new to Clojure? > Yes. It will become easier with experience. That piece of code looks very explicit and readable to me, al

Re: Neighbors function from The Joy of Clojure

2014-11-04 Thread Pierre Thibault
Ouch! I found this code hard to understand. I read to previous part of the book. I guess it is normal when you are new to Clojure? -- 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

Re: Neighbors function from The Joy of Clojure

2011-09-14 Thread Chouser
On Wed, Sep 14, 2011 at 3:35 PM, Fogus wrote: >> diagonals as neighbors.  We don't think we take advantage of the >> flexibility anywhere in the book, so perhaps your version would indeed >> be better. I meant to say "I" didn't think. Sorry, didn't mean to put words in your mouth, Fogus. > It w

Re: Neighbors function from The Joy of Clojure

2011-09-14 Thread Leonardo Borges
It certainly helped :) I played around with it last night after chouser's response and it all made sense, thanks! Cheers, Leonardo Borges www.leonardoborges.com On 15/09/2011, at 1:39 AM, Sean Corfield wrote: > On Wed, Sep 14, 2011 at 5:58 AM, Leonardo Borges > wrote: >> (defn neighbors >>

Re: Neighbors function from The Joy of Clojure

2011-09-14 Thread Fogus
> diagonals as neighbors.  We don't think we take advantage of the > flexibility anywhere in the book, so perhaps your version would indeed > be better. It was used again only briefly in section 11.2 to define the legal moves that a king can make in chess, which of course includes diagonals. :-)

Re: Neighbors function from The Joy of Clojure

2011-09-14 Thread Sean Corfield
On Wed, Sep 14, 2011 at 5:58 AM, Leonardo Borges wrote: > (defn neighbors >   ([size yx] (neighbors [[-1 0] [1 0] [0 -1] [0 1]] size yx)) >   ([deltas size yx] >     (filter (fn [new-yx] >               (every? #(< -1 % size) new-yx)) >      (map #(map + yx %) deltas > > This syntax made me sc

Re: Neighbors function from The Joy of Clojure

2011-09-14 Thread Leonardo Borges
Ah, got ya. Did not think of that :) Thanks for the insight! Cheers, Leonardo Borges www.leonardoborges.com On Wed, Sep 14, 2011 at 11:29 PM, Chouser wrote: > On Wed, Sep 14, 2011 at 8:58 AM, Leonardo Borges > wrote: >> Hi Guys, >> I'm pretty new to clojure and to the list as well - this bei

Re: Neighbors function from The Joy of Clojure

2011-09-14 Thread Chouser
On Wed, Sep 14, 2011 at 8:58 AM, Leonardo Borges wrote: > Hi Guys, > I'm pretty new to clojure and to the list as well - this being my 1st > message - so hello everyone :) > I'm going through the book The Joy of Clojure which, pardon the pun, > I'm enJOYing a lot and stumbled upon this function to

Neighbors function from The Joy of Clojure

2011-09-14 Thread Leonardo Borges
Hi Guys, I'm pretty new to clojure and to the list as well - this being my 1st message - so hello everyone :) I'm going through the book The Joy of Clojure which, pardon the pun, I'm enJOYing a lot and stumbled upon this function to find neighbors of a location in a 2D matrix: (defn neighbors   ([