The closest thing to currying in Clojure is the partial function. It is so similar on the surface that, when the topic comes up in online discussions, the answer is usually that Clojure supports currying, and you can do this using partial .

The idea of both currying and partial is that when you apply a function with fewer arguments than it requires, instead of throwing an error, the function closes over what's there and creates a new function that awaits for the remaining arguments. The main difference is that partial is a higher order function that has to be called explicitly, while currying is automatic.

This function takes exactly 4 arguments.

( defn add4 [ x y z w ] ( + x y z w ) )

If we call it with exactly four, it adds them.

( add4 1 2 3 4 )

10

However, if we call it with only two, it throws an ArrityException .

( add4 1 2 )

class clojure.lang.ArityExceptionclass clojure.lang.ArityExceptionArityException Wrong number of args (2) passed to: user/add4 clojure.lang.AFn.throwArity (AFn.java:429)

Often, only some arguments are known at some point in time. Later they are repeated. Instead of keeping track of them all the time, we would like to somehow fill them in, and be able to supply the rest at an appropriate time in future. partial is just what we need. An example would be supplying a database connection to a function that generates queries.

( def add2 ( partial add4 1 2 ) )

The resulting function add2 does the same thing as add4 , but it "remembers" arguments 1 and 2 , and can return the answer once the remaining arguments are known.

( add2 3 4 )

10