Currying, partially applying arguments to functions, in Clojure.
The function partial
accepts a function and some, but not all, of the arguments for that function. It returns a new function which accepts the remaining arguments. This is known as currying.
Using the function <
, which accepts two arguments, as an example we can use partial
to apply to the first argument and return a new function which accepts the second.
The function <
accepts two arguments:
1


We can create a new function with just 25
applied:
1


If we define a var and store the function returned by partial
we can use it as follows:
1 2 3 4 

Since partial
returns a function it can be used with highorder functions such as map
.
1


The function map
accepts a function (which accepts one argument) and a collection, the function is applied to each item in the collection.