Created
October 15, 2018 15:25
-
-
Save vastus/0dba2f967c22771eac092be00a5e6d4c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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