There may be a more elegant way of doing what you want, but here is at least a more general version:
(defn delayed [reducer & fs] (apply reducer (for [f fs] (if (fn? f) (f) f)))) (def a-fn (partial delayed +))
So, delayed accepts an arbitrary function and a list of function values ββ/. If extends all arguments and then applies a function to them. Then we use partial to determine your a-fn with + :
user=> (a-fn 1 2) 3 user=> (a-fn (constantly 1) 2) 3 user=> (a-fn (constantly 1) 2 4) 7
Alternatively, for delayed may need to return a function, rather than using a partial one. Notice which is better.
Better name than "delay" is welcome :)
source share