2 ms·
Partial application is applied on call site, currying at definition. Currying: const f = x => y => x + y; const g = f(1); const sum = g(2); P
by k__ 9y ago
Partial application is applied on call site, currying at definition.
Currying:
const f = x => y => x + y;
const g = f(1);
const sum = g(2);
Partial application:
const f = (x, y) => x + y;
const g = _ => f(1, _);
const sum = g(2);
Most FP languages have nicer syntax for this.
- gmfawcett 9y agoThat's not what currying is. You've just used partial application in two different contexts. Currying takes a multi-argument function: const f = (x, y, z) => x + y * z; ...and converts it to a function that takes a single argument, and returns a function taking the next argument, recursively: const f_curried = x => y => z => x + y * z; const result = f_curried(1)(2)(3) edit: maybe you were trying to convey that, in your first example, f is already a curried function? As a whole, the first example just looks like a partial-application demonstration.