On Fri, Aug 28, 2015 at 5:33 PM, Atamert Ölçgen <mu...@muhuk.com> wrote:
> Also, you know about as->, don't you? Well, I'm aware of all other threading forms like some->, as->, etc. This is just something I'm trying with -> and ->>, and thought I'd discuss. Perhaps the definition of as-> can be used as a better premise. But, as-> is entirely different and simpler shape that uses interleave. On Friday, August 28, 2015 at 5:34:24 PM UTC+5:30, Atamert Ölçgen wrote: > > Hi, > > threading doesn't need to be a macro. In fact it would be easier to test > if it's just a function. > > Also, you know about as->, don't you? > > > On Fri, Aug 28, 2015 at 2:37 PM, Akhil Wali <green.tr...@gmail.com > <javascript:>> wrote: > >> I've been trying to refactor the -> and ->> forms to use a common macro >> form. >> Ended up with this. >> >> (defmacro threading [a b x forms] >> (loop [x x >> forms forms] >> (if forms >> (let [form (first forms) >> f (first form) >> r (rest form) >> threaded (if (seq? form) >> (with-meta >> `(~f ~`(~a ~`(list ~x ~@r)) >> ~`(~b ~`(list ~x ~@r))) >> (meta form)) >> (list form x))] >> (recur threaded (next forms))) >> x))) >> >> (defmacro -> [x & forms] >> `(threading ~'first ~'second >> ~x ~forms)) >> >> (defmacro ->> [x & forms] >> `(threading ~'second ~'first >> ~x ~forms)) >> >> >> This does work, but it's a bit of whammy. >> Anyone with suggestions for improvement? >> >> -- >> 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 >> <javascript:> >> 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 <javascript:> >> 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+u...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Kind Regards, > Atamert Ölçgen > > ◻◼◻ > ◻◻◼ > ◼◼◼ > > www.muhuk.com > -- 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.