From 3a940a794a3163767fbb00299f4c51d2f8f15039 Mon Sep 17 00:00:00 2001 From: Edoardo La Greca Date: Thu, 4 Sep 2025 20:48:10 +0200 Subject: add rest of sixth exercise of lecture 6 --- lec06/Fibonacci.hs | 5 +++++ 1 file changed, 5 insertions(+) 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)) -- cgit v1.2.3