On Monday, February 18, 2013 5:40:51 PM UTC+1, vemv wrote:

>
> And neither can be solved by adding a lambda:
>
> (-> [[1 1 1] 2 3] (nth 0) #(map inc %)) ;; fail
>

Lambda does solve it, you are just missing the parens around the lambda:

(-> [[1 1 1] 2 3] (nth 0) (#(map inc %)))
 


> Clojure 1.5's as->, though, can come to the rescue.
>
> (-> [[1 1 1] 2 3] (nth 0) (as-> x (map inc x))) ;; cool
>
> Now, I only wish 1.5 came with as->> macro! Its implemetation is trivial 
> anyway.
>
> (->> [1 2 3] (as->> _ (nth _ 0)))
>
> Of course, for the given examples, using these "as" forms is overkill. But 
> if you've ever ended up writing large expressions (especially when 
> experimenting) which arbitrarily nest/interleave ->> and ->, using as-> and 
> as->> can provide a more sequential, structured alternative.
>
> Couldn't find any related discussion about the uses of as->, as its name 
> is unfriendly to Google/JIRA searches. Thoughts?
>

as-> is actually a generalization of both -> and ->>: you get to choose 
where to involve the previous result in each form. That is why as->> would 
be redundant.

-Marko

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