> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
These macros are collectively called the "threading macros". `->` is
called "thread first" and `->>` is called "thread last". These macros
lets you write deeply nested function invocations in a relatively flat
manner.
Something like
(-> foo
(bar x)
(baz y)
(quux z))
gets re-written as (quux (baz (bar foo x) y) z). So `->` basically
threads the first expression through the subsequent forms, inserting
it as the second item in the list (aka the first arg).
Similarly, something like
(->> foo
(bar x)
(baz y)
(quux z))
gets re-written as (quux z (baz y (bar x foo))).
More docs here - http://clojuredocs.org/clojure_core/clojure.core/-%3E
& http://clojuredocs.org/clojure_core/clojure.core/-%3E%3E
Regards,
BG
--
Baishampayan Ghose
b.ghose at gmail.com
Oh, no. Not again!
https://groups.google.com/forum/?fromgroups#!topic/clojure/6Cb8MD5EC3w
> Could anyone point me to a description of "->" and "->>", please?
Another thing to check out is Fogus' nice write up (and links) about these and other "thrushy" combinators:
http://blog.fogus.me/2010/09/28/thrush-in-clojure-redux/
bill