Indeed! You can use ->> (like ->, but inserts into the last position of
each form) to do something like:
(defn neighbors
([size yx]
(neighbors [[-1 0] [1 0] [0 -1] [0 1]] size yx))
([deltas size yx]
(let [in-matrix? (fn [new-yx] (every? #(< -1 % size) new-yx))]
(->> deltas
(map #(map + yx %))
(filter in-matrix?)))))
On Thursday, July 5, 2012 3:08:57 PM UTC-7, Jacobo Polavieja wrote:
>
>
> After this post my mind started thinking... Isn't there a way so I don't
> have to go "inside-out" thinking and be more like the pattern of first do
> f1 on x1, then apply f2 to the prior result, then do f3 to the prior
> result...
> Seems like the (->) gives some taste of what I'm looking for:
> http://stackoverflow.com/questions/6145002/operator-in-clojure
>
> So in short, is the function I had doubts with idiomatic clojure. Isn't
> there a simpler way? I have no doubt if there is the book didn't put it in
> any other way because it would involve concepts not yet explained, I'm just
> curious...
>
> Cheers!
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en