summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdoardo La Greca2025-09-04 20:48:10 +0200
committerEdoardo La Greca2025-09-04 20:48:10 +0200
commit3a940a794a3163767fbb00299f4c51d2f8f15039 (patch)
treed94b2150c6f7fdef3fe79b3f168ccf001464093c
parentaa9625ea413f9c7f191aefc75f29c74e7dea0b9f (diff)
add rest of sixth exercise of lecture 6
-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))