I have a feature vector (def my-func [a b c d]). Each function takes the output of the last function as input. I want to stream through them through them, how to do it?
(def my-func [a b c d])
How to proceed to the next form (-> in a b c d)?
(-> in a b c d)
Thank you Murtaza
You can use comp, but keep in mind that it performs functions from right to left
comp
((comp d c b a) 10)
or
((apply comp my-fns) 10)
will pass 10 to the first function, the result to the next function and so on.
I think you can use the function reduce:
reduce
(def fns [inc inc inc]) (reduce (fn [v f] (f v)) 10 fns)