summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lec06/Fibonacci.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/lec06/Fibonacci.hs b/lec06/Fibonacci.hs
index 375e5ef..863e11a 100644
--- a/lec06/Fibonacci.hs
+++ b/lec06/Fibonacci.hs
@@ -61,4 +61,9 @@ instance Num (Stream Integer) where
where zip (Cons a0 sa) (Cons b0 sb) = Cons (a0,b0) (zip sa sb)
(*) (Cons a0 sa) b@(Cons b0 sb) = Cons (a0*b0) $ (streamMap (*a0) sb + (sa*b))
+instance Fractional (Stream Integer) where
+ (/) a@(Cons a0 sa) b@(Cons b0 sb) = Cons (a0 `div` b0) $ streamMap (`div` b0) (sa-(a/b)*sb)
+
+fibs3 :: Stream Integer
+fibs3 = x / (1 - x - (x*x))