Is there a function that exists in clojure similar to reduce, but that can pass in a variable?
For example, say I wanted to implement my own filter function and pass in a predicate to check the entire collection against and retain the values that satisfy the predicate, is there an idiomatic way of doing this while using reduce?
My guess would be to do the following:
(->> coll
(map #(:val % :pred pred))
(reduce my-filter-fn {:val 0 :pred pred}))
Essentially just creating a collection of maps that have the value I need to pass into the reduce function.
I've found the use case of needing to pass in values to the reduce function somewhat frequently, but it may because I'm not thinking in the appropriate functional way. Is there a more idiomatic solution?