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 ([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 scratch my head since I believe it was the first time I saw it. However, upon closer analysis it seems it could be rewritten like this, yielding the same result: (defn neighbors-1 [size yx] (let [deltas [[-1 0] [1 0] [0 -1] [0 1]]] (filter (fn [new-yx] (every? #(< -1 % size) new-yx)) (map #(map + yx %) deltas)))) The second version feels a lot easier on my eyes. Am I missing something or they are really equivalent? And if so, why is the first syntax supported or better yet, when is it best to use it? Cheers, Leonardo Borges www.leonardoborges.com -- 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