Permalink
Browse files

New example: EvenDouble in the generator style, rathen than as a tail…

… recursive function (so we get fusion)
  • Loading branch information...
1 parent e1a8ae8 commit 3380c4be6a67c6c7d6fd84103afd0e1fd7d2fa54 @batterseapower committed Jul 19, 2010
Showing with 14 additions and 0 deletions.
  1. +13 −0 examples/toys/EvenDoubleGenerator.core
  2. +1 −0 examples/toys/EvenDoubleGenerator.hs
@@ -0,0 +1,13 @@
+double y = case y of Z -> Z
+ S x -> S (S (double x))
+
+even y = case y of Z -> True
+ S z -> case z of Z -> False
+ S x -> even x
+
+root x = even (double x)
+
+tests = [
+ (root Z, True),
+ (root (S Z), True)
+ ]
@@ -0,0 +1 @@
+data Nat = Z | S Nat

0 comments on commit 3380c4b

Please sign in to comment.