On Fri, Aug 28, 2015 at 11:51 PM, Alan Thompson <clooj...@gmail.com> wrote:
> I have become very partial to a simple adaptation of as-> from the Tupelo > Core <https://github.com/cloojure/tupelo> library. I almost always like > to be explicit about the location the previous value, since either -> or > ->> can sometimes be difficult if the threading forms don't always want the > arg as the first or last parameter. > You've likely seen it, but https://github.com/rplevy/swiss-arrows has -<> and -<>>, which capture "<>" for placement, and default to either the first or last position when not present in an expression. IIRC they don't require wrapping all expressions in lists, a difference from it-> - e.g. (-<> 1 inc (* 5) (/ 4 <> 3)). I haven't used the library, but would expect readability to be improved by allowing the placeholder to be omitted except when needed. I was/am an enthusiast of the "cut" macro from SRFI-26 (which uses <>) - I think cut-> and cut->> scan much better than -<>>. > Copying the pattern of Groovy/Ruby, I almost always name the threading > placeholder "it". Since I don't like repetition (& I would argue that the > as-> form has its params backwards!) > The parameter ordering seems awkward, but enables embedding within thread-first. The example above becomes (-> 1 inc (* 5) (as-> it (/ 4 it 3))) (2/15, in case you were curious) Take care, Moe -- 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/d/optout.