Last active
July 4, 2021 02:31
-
-
Save nmorse/560a72e129a32b629c48ae74eee99013 to your computer and use it in GitHub Desktop.
In which some of the Church encodings of Boolean logic are converted to Pounce-lang (after reading github.com/glebec/lambda-talk)
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
# Church encodings for boolean logic. | |
# `T` is for true, any other word is false (e.g. `F` ) | |
# Evaluation of Church encoded logic (in pounce) will be composed as '^' | |
## if top of the stack is `T` then take the first (i.e. drop), else keep the second (i.e. swap drop) | |
[T == [drop][swap drop] if-else] [^] compose | |
# 'AND' in lambda calculus is \pq.pqp. Translated to post-fix `[p q] [p q q ^] pounce` | |
## or more simply `dup ^` | |
[dup ^] [and] compose | |
# 'OR' in the lambda calculus is \pq.qqp. In post-fix `[p q] [p q p ^] pounce` | |
## or `[dup] dip swap ^` | |
[[dup] dip swap ^] [or] compose | |
# 'NOT in the lambda calculus is \p.pFT and in post-fix `[p] [f t p ^] pounce` | |
## or `[f t] dip ^` | |
[[F T] dip ^] [not] compose | |
'AND' | |
F F and | |
F T and | |
T F and | |
T T and | |
'OR' | |
F F or | |
F T or | |
T F or | |
T T or | |
'NOT' | |
T not | |
F not |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment