Explorar o código

Add convertor from int to Nat

DricomDragon %!s(int64=5) %!d(string=hai) anos
pai
achega
715cd0c58c
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      peano.hs

+ 3 - 0
peano.hs

@@ -3,3 +3,6 @@ data Nat = Zero | Succ Nat
 intValOf thisNat = case thisNat of
 	Zero -> 0
 	Succ nextNat -> 1 + intValOf nextNat
+
+natValOf thisInt = if thisInt == 0 then Zero else Succ (natValOf (thisInt - 1))
+