Guest User

Untitled

a guest
Feb 24th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. Implement, as best as you can, the identity function in your favorite language
  2. (or the second favorite, if your favorite language happens to be Haskell).
  3.  
  4. ```
  5. const identity = x => x;
  6. ```
  7.  
  8. Implement the composition function in your favorite language.
  9. It takes two functions as arguments and returns a function that is their composition.
  10.  
  11. ```
  12. const composition = (f, g) => (x => g(f(x)))
  13. ```
  14.  
  15. Write a program that tries to test that your composition function respects identity.
  16.  
  17. ```
  18. const f = x => `f(${x})`;
  19. composition(f, identity)('x'); //"f(x)"
  20. composition(identity, f)('x');
  21. ```
  22. Is the world-wide web a category in any sense? Are links morphisms?
  23. Yes.
  24.  
  25. Is Facebook a category, with people as objects and friendships as morphisms?
  26. Yes, kind of.
  27.  
  28. When is a directed graph a category?
Add Comment
Please, Sign In to add comment