changeset 2168:544199d8b14a

Fix termination bug in tutorial's isEven/isOdd
author Adam Chlipala <adam@chlipala.net>
date Sun, 09 Aug 2015 11:14:09 -0400
parents a9dc205edd78
children 3acaaff30c85
files doc/intro.ur
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/doc/intro.ur	Thu Aug 06 12:51:09 2015 -0400
+++ b/doc/intro.ur	Sun Aug 09 11:14:09 2015 -0400
@@ -58,12 +58,15 @@
 fact 5
 (* end *)
 
-fun isEven n = n = 0 || isOdd (n - 1)
-and isOdd n = n = 1 || isEven (n - 1)
+fun isEven n = n = 0 || (n > 1 && isOdd (n - 1))
+and isOdd n = n = 1 || (n > 1 && isEven (n - 1))
 
 (* begin eval *)
 isEven 32
 (* end *)
+(* begin eval *)
+isEven 31
+(* end *)
 
 
 (* Of course we have anonymous functions, too. *)