Created
December 1, 2017 21:45
-
-
Save SergProduction/2899693bf491b36bea3009d503065792 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function cons(a, b) { | |
| return p => p(a)(b) | |
| } | |
| function car(pair) { | |
| return pair(a => b => a) | |
| } | |
| function cdr(pair) { | |
| return pair(a => b => b) | |
| } | |
| console.log(car(cons('a', 'b')) == 'a'); | |
| console.log(cdr(cons('a', 'b')) == 'b'); | |
| console.log(cdr(cdr(cons('a', cons('b', 'c')))) == 'c'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment