I'm a Python programmer just learning Clojure. In Python I love how I can used named arguments in a call to functools.partial:
def pow(base, exponent):
return base ** exponent
exp = partial(pow, 2.71828) # exp(2) --> 7.3886
square = partial(pow, exponent=2) # square(2) --> 4
The implementation of exp
is is obviously equivalent in Clojure - but could I use partial
to define square
succinctly, too? Is there a way to pass in keyword/named arguments to partial so that a specific argument is pre-determined? Or would this have to be handled not by partial
but a function literal, e.g. #(pow % 2)
?