I need to implement a function (flow) that makes a functional composition of its two arguments.
Requirements:
- The
flowfunction should take two functions as arguments (calledfabandfbc) and return a new function that appliesfabto its input parameter and then appliesfbcto the resulting value.
Hints:
- The first function is called
fabbecause it maps a value from typeAto typeB. The same forfbc.
The problem is that I don't know what to pass as a parameter to fab function, I'm a Typescript newbie, would appreciate any help!
This is my code so far:
type Flow = <A, B, C>(
fab: (a: A) => B, // Takes a function from A to B
fbc: (b: B) => C // Takes a function from B to C
) => (a: A) => C; // Returns a function from A to C
export const flow: Flow = (fab, fbc) => {
return fbc(fab());
};
return a => fbc(fab(a));typescriptlang.org/play?#code/…