Skip to content

Instantly share code, notes, and snippets.

@sabithpocker
Created February 12, 2018 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sabithpocker/b54852c0b1321189ae9d0ead2a6bf458 to your computer and use it in GitHub Desktop.
Save sabithpocker/b54852c0b1321189ae9d0ead2a6bf458 to your computer and use it in GitHub Desktop.
Implement, as best as you can, the identity function in your favorite language
(or the second favorite, if your favorite language happens to be Haskell).
```
const identity = x => x;
```
Implement the composition function in your favorite language.
It takes two functions as arguments and returns a function that is their composition.
```
const composition = (f, g) => (x => g(f(x)))
```
Write a program that tries to test that your composition function respects identity.
```
const f = x => `f(${x})`;
composition(f, identity)('x'); //"f(x)"
composition(identity, f)('x');
```
Is the world-wide web a category in any sense? Are links morphisms?
Yes.
Is Facebook a category, with people as objects and friendships as morphisms?
Yes, kind of.
When is a directed graph a category?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment