#+title: partial application Partial application is a form of [[file:20210314121301-functional_application.org][functional application]] wherein the first =n= arguments are bound. This is not to be confused with [[file:20210607204228-currying.org][currying]], In [[file:20200720132835-javascript.org][JavaScript]] in particular, a built-in method on functions called =.bind= can accomplish this: #+begin_src js :results output const add = (x, y) => x + y; const add10 = add.bind(null, 10); console.log(add10(20)); #+end_src #+RESULTS: : 30 We could implement a free function as such in [[file:20210607203539-typescript.org][TypeScript]]: #+begin_src typescript type Variadic = (...args: any[]) => R; function partial(fn: Variadic, ...args: any[]): Variadic { return function(...rest: any[]) { return fn(...args, ...rest); } } const add = (x: number, y: number): number => x + y; const add10 = partial(add, 10); console.log(add10(100)); #+end_src #+RESULTS: : 110