Hi Mark, 2009/11/13 Mark Tomko <mjt0...@gmail.com>: > > I notice you used the '->' macro. Perhaps I'm a little dense, but I > haven't found the documentation for it to be terribly helpful. Do you > have simple, succinct explanation for what it does?
The -> macro calls the given forms with the return value of previous form inserted as the first argument of the subsequent form. Maybe an example will help ;-) (-> v (assoc i (v j)) (assoc j (v i)))) You can think of this as v -> (assoc $ i (v j)) -> (assoc $ j (v i)) where the $ placeholder is replaced by the value from the left of the arrow. The above example translates to this: (assoc (assoc v i (v j)) j (v i)) i.e. v is placed into the first assoc form which is then placed into the second assoc form. The macro helps you thread a chain of computations together where the later forms want to use the return value of the preceding form. Very useful with persistent data structures where you have to thread the returned data structure through a number of functions. > Thanks! I hope this helps. I don't think I did a particularly good job in explaining how the macro works... > Mark -- ! Lauri -- 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