Skip to content

Instantly share code, notes, and snippets.

@taiju
Last active October 9, 2017 12:10
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 taiju/1725a55664ca39a1865f095337887a36 to your computer and use it in GitHub Desktop.
Save taiju/1725a55664ca39a1865f095337887a36 to your computer and use it in GitHub Desktop.
const two = (s) => (z) => (s) ((s) (z))
const three = (s) => (z) => (s) ((s) ((s) (z)))
const mult = (m) => (n) => (s) => (z) => (n) ((m) (s)) (z)
const toInt = (n) => (n) (x => x + 1) (0)
// six = (mult) (two) (three)
// six = ((m) => (n) => (s) => (z) => (n) ((m) (s)) (z)) ((s) => (z) => (s) ((s) (z))) ((s) => (z) => (s) ((s) ((s) (z))))
// six = ((m) => (n) => (s) => (z) => (n) ((m) (s)) (z)) ((x) => (y) => (x) ((x) (y))) ((a) => (b) => (a) ((a) ((a) (b))))
// six = ((n) => (s) => (z) => (n) (((x) => (y) => (x) ((x) (y))) (s)) (z)) ((a) => (b) => (a) ((a) ((a) (b))))
// six = ((n) => (s) => (z) => (n) ((y) => (s) ((s) (y))) (z)) ((a) => (b) => (a) ((a) ((a) (b))))
// six = (s) => (z) => ((a) => (b) => (a) ((a) ((a) (b)))) ((y) => (s) ((s) (y))) (z)
// six = (s) => (z) => ((b) => ((y) => (s) ((s) (y))) (((y) => (s) ((s) (y))) (((y) => (s) ((s) (y))) (b)))) (z)
// six = (s) => (z) => (((y) => (s) ((s) (y))) (((y) => (s) ((s) (y))) (((y) => (s) ((s) (y))) (z))))
// six = (s) => (z) => (((y) => (s) ((s) (y))) ((s) ((s) ((s) ((s) (z))))))
const six = (s) => (z) => (s) ((s) ((s) ((s) ((s) ((s) (z))))))
; // wtf
(toInt) (six) // => 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment