Hacker News new | past | comments | ask | show | jobs | submit login

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.



That'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.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: