I'm not quite sure what you want to do here in the general case but.....a few thoughts:
-> is implemented as a macro, whereas reduce and reductions are functions. Depending on what you really want you may need a macro over a function. Note that reduce is picky about the reducing function it takes: it must be function of two arguments. This is very different from the operation of the threading macro (->). If you want to implement this as a function, you might look at the implementation of juxt or comp for ideas since they are HOFs (functions taking other functions as arguments). If functions f, g, and h all take one argument you can implement the specific example you show as: ((juxt f (comp g f) (comp h g f)) 1) For functions of one argument this could be generalized to take multiple arguments and return vectors of composed applications: (defn intermediates [fns] (let [f (fn [x] ((apply juxt (map #(apply comp (reverse (take %1 fns))) (range 1 (inc (count fns))))) x)) ] (fn [& xs] (map f xs)) )) (def f inc) (defn g [x] (* x 2)) (defn h [n] (+ n 5)) ((intermediates [f g]) 5) ;=> ([6] [12]) ((intermediates [f g h]) 5) ;=> ([6 12 17]) ((intermediates [f g h]) 5 7 9) ; each vector is [(f x) (g (f x)) (h (g (f x)))] ;=> ([6 12 17] [8 16 21] [10 20 25]) cheers, -tom On Sunday, March 1, 2015 at 2:16:06 PM UTC-7, Bill Allen wrote: > > Hopefully that makes sense. Let me illustrate. > > (reduce + [1 2 3 4]) > ;=> 10 > (reductions + [1 2 3 4) > ;=> (1 3 6 10) > > (-> 1 f g h) > ;=> (h (g (f 1))) > > I'm hoping to get a function that behaves like: > (--> 1 f g h) > ;=> ((f 1) (g (f 1) (h (g (f 1)))) > > Any ideas? > > Regards, > Bill > > -- 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.