Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type Incrementer = (x: number) => number;
- const increment: Incrementer = x => x + 1;
- console.assert(increment(2) == 3)
- type Tostr = (x: number) => string;
- const tostr: Tostr = (x: number) => `"${x}"`
- console.assert(tostr(2) == `"2"`)
- type Composer = <A, B, C> (
- f: (x: B) => C,
- g: (x: A) => B,
- ) => (x: A) => C
- const compose: Composer = (f, g) => x => f(g(x))
- type IncrNTostr = (x: number) => string
- const incrNTostr: IncrNTostr = compose(tostr, increment)
- console.assert(incrNTostr(5) == `"6"`)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement