123456789101112131415161718 |
- -- Slide 28
- data Nat = Zero | Succ Nat deriving Show
- intValOf thisNat = case thisNat of
- Zero -> 0
- Succ nextNat -> 1 + intValOf nextNat
- natValOf thisInt = if thisInt == 0 then Zero else Succ (natValOf (thisInt - 1))
- addition aNat tinyNat = case tinyNat of
- Zero -> aNat
- Succ tinierNat -> Succ (addition aNat tinierNat)
- additiont aNat tinyNat = case tinyNat of
- Zero -> aNat
- Succ tinierNat -> additiont (Succ aNat) tinierNat
|