소스 검색

Add convertor from int to Nat

DricomDragon 5 년 전
부모
커밋
715cd0c58c
1개의 변경된 파일3개의 추가작업 그리고 0개의 파일을 삭제
  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))
+