Created
November 15, 2019 20:11
-
-
Save dyokomizo/b8d40624eceec531412789cfeca54795 to your computer and use it in GitHub Desktop.
Peano in Haskell
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
$ ghci | |
GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help | |
Prelude> let z = \s z -> z | |
Prelude> let s = \n s z -> s $ n s z | |
Prelude> let unchurch n = n (+1) 0 | |
Prelude> unchurch z | |
0 | |
Prelude> let n1 = s z | |
Prelude> let n2 = s $ s z | |
Prelude> let n3 = s $ s $ s z | |
Prelude> unchurch n1 | |
1 | |
Prelude> unchurch n2 | |
2 | |
Prelude> unchurch n3 | |
3 | |
Prelude> unchurch $ n2 n3 | |
9 | |
Prelude> unchurch $ n3 n2 | |
8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment