Currying, partially applying arguments to functions, in Clojure.
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.
< accepts two arguments:
We can create a new function with just
If we define a var and store the function returned by
partial we can use it as follows:
1 2 3 4
partial returns a function it can be used with high-order functions such as
map accepts a function (which accepts one argument) and a collection, the function is applied to each item in the collection.