functional programming - Clojure - more idiomatic to return a closure, or partially apply the function? -
i'm using external library, , passing function write. this, example: (ext-func my-func) ... my-func needs given data computation. way see it, have 2 basic choices: 1) write my-func in such way accepts data, , returns function, have data bound via closure when external library calls it. example: (defn my-func [mydata] (fn [] (... access mydata via closure ... ))) (ext-func (my-func somedata)) 2) not return function my-func , bind data when pass ext-func : (defn my-func [mydata] (... evaluate, use mydata, etc.)) (ext-func (partial my-func somedata)) i suppose 1 use answered how intend use function otherwise. if i'm going using other places, may prefer not return function, example. but, other things being equal... ...which of these more idiomatic approach? partial sugar create anonymous function. check out it's source . so, they're equivalent. take pick. neither more idiomatic, matter of personal preference.