Skip to content

Instantly share code, notes, and snippets.

@vastus
Created October 15, 2018 15:25
Show Gist options
  • Select an option

  • Save vastus/0dba2f967c22771eac092be00a5e6d4c to your computer and use it in GitHub Desktop.

Select an option

Save vastus/0dba2f967c22771eac092be00a5e6d4c to your computer and use it in GitHub Desktop.
function compose2<T, U>(g: (n: T) => U, f: (m: T) => T) {
return function (x: T) {
return g(f(x));
}
}
const inc = (x: number) =>
x + 1;
const add = (x: number) => (y: number) =>
x + y;
const toStr = (x: number) =>
`${x}`;
const comp = compose2(
inc,
add(40),
)
const res = comp(1);
console.log(res);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment