Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. function compose (f,g){
  2. function inner(x,y){
  3. return console.log(f(g(x,y)));
  4. }
  5. return inner;
  6. }
  7. function addSum(x,y){
  8. return x+y;
  9. }
  10. function addOne(x){
  11. return x+1;
  12. }
  13. function square(x){
  14. return x*x;
  15. }
  16. compose(addOne,square)(5);
  17. compose(Math.cos, addOne)(-1);
  18. compose(addOne, Math.cos)(-1);
  19. var compositeFunction = compose(Math.sqrt, Math.cos);
  20. console.log(compositeFunction(0.5));
  21. console.log(compositeFunction(1));
  22. console.log(compositeFunction(-1));
  23. compose(addOne, addSum)(5, 6);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement