Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function compose (f,g){
- function inner(x,y){
- return console.log(f(g(x,y)));
- }
- return inner;
- }
- function addSum(x,y){
- return x+y;
- }
- function addOne(x){
- return x+1;
- }
- function square(x){
- return x*x;
- }
- compose(addOne,square)(5);
- compose(Math.cos, addOne)(-1);
- compose(addOne, Math.cos)(-1);
- var compositeFunction = compose(Math.sqrt, Math.cos);
- console.log(compositeFunction(0.5));
- console.log(compositeFunction(1));
- console.log(compositeFunction(-1));
- compose(addOne, addSum)(5, 6);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement