Peano arithmetic
Peano arithmetic
(mathematics)This could be expressed as a recursive data type with thefollowing Haskell definition:
data Peano = Zero | Succ Peano
The number three, usually written "SSS0", would be Succ (Succ(Succ Zero)). Addition of Peano numbers can be expressed as asimple syntactic transformation:
plus Zero n = nplus (Succ m) n = Succ (plus m n)