That was added to clojure.core in 1.6 and is known as "as->" https://clojuredocs.org/clojure.core/as-%3E
On Sat, Nov 15, 2014 at 6:55 AM, Krzysiek Herod <krzysiek.he...@gmail.com> wrote: > Guys, what do you think about new thread macro (I would call it thread-any > and represent it as "%>"), that would require you to always specify the > position of the argument you want to pass to the function? > > This code: > > (defn csv-line->sql-line [table, line] > (-> line > (str " ") > (str/split separator) > (#(map csv-field->sql-field %)) > (#(str/join ", " %)) > (str/replace strings-wrapper "\"") > (#(str "INSERT INTO ", table, " VALUES(" % ");")))) > > would become: > > (defn csv-line->sql-line [table, line] > (%> line > (str % " ") > (str/split % separator) > (map csv-field->sql-field %) > (str/join ", " %) > (str/replace strings-wrapper % "\"") > (str "INSERT INTO ", table, " VALUES(" % ");"))) > > Reasoning: > - there are functions that are "thread-first fiendly", and other that are > "thread-last friendly", by using thread-in you don't have to redefine > functions only to change the order of the attributes > - I find it easier to follow execution chain if the argument is passed > explicitely > > PS. I'm a clojure newbie, still in the process of learning basics. For > example I'm not sure how to implement such macro yet, so if you find > something obviously wrong, or missing in my suggestion, please let me know. > I'll be super happy to read about alternative solutions to achieve similar > goal. > > -- > 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. > -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- 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.