Skip to content

Instantly share code, notes, and snippets.

@dyokomizo
Created November 15, 2019 20:11
Show Gist options
  • Save dyokomizo/b8d40624eceec531412789cfeca54795 to your computer and use it in GitHub Desktop.
Save dyokomizo/b8d40624eceec531412789cfeca54795 to your computer and use it in GitHub Desktop.
Peano in Haskell
$ 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