This is a great question!
First let's define arity as the number of arguments a function takes. This function is 2 arity.
arity
const add = (x, y) => x + y
Currying is taking a 2+ arity function and splitting it into many 1 arity functions.
So if we were to curry add, it would look like this:
add
const add = x => y => x + y
Now I would call the add function like this:
add (3) (4) //=> 7
Partial application is used with curried functions to partially apply arguments.
const add3 = add (3) add3 (4) //=> 7
But partial application is not specific to curried functions either. For example, you could partially apply any non-curried function using bind.
bind
const add = (x, y) => x + y const add3 = add.bind(null, 3) add3 (4) //=> 7
I hope that has been helpful!
Cheers!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This is a great question!
First let's define
arity
as the number of arguments a function takes. This function is 2 arity.Currying is taking a 2+ arity function and splitting it into many 1 arity functions.
So if we were to curry
add
, it would look like this:Now I would call the
add
function like this:Partial application is used with curried functions to partially apply arguments.
But partial application is not specific to curried functions either. For example, you could partially apply any non-curried function using
bind
.I hope that has been helpful!
Cheers!