Last active
January 13, 2017 00:04
-
-
Save jbarnette/751075eb3271bc12b9a32273576a7628 to your computer and use it in GitHub Desktop.
This file contains 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
@discardableResult func cons(_ x: Any, _ y: Any) -> (((Any, Any) -> Any) -> Any) { | |
return { m in m(x, y) } | |
} | |
@discardableResult func car(_ z: (((Any, Any) -> Any) -> Any)) -> Any { | |
return z { p, q in p } | |
} | |
@discardableResult func cdr(_ z: (((Any, Any) -> Any) -> Any)) -> Any { | |
return z { p, q in q } | |
} | |
car(cons(1, 2)) | |
cdr(cons(1, 2)) | |
print(car(cons(1, cons(2, 3)))) // => 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment