X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=Adders.hs;h=d4dbbf8c99d851b5c7cf7b49222ca994b42c8878;hb=eb3177ed5e53fd27bc64a45584ab646545c27e5f;hp=e6676e94888f3ce0bec9c9a489672da8288200e0;hpb=52d5de13a6c89e7dbc46627888210ddcda1c3e6c;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git diff --git a/Adders.hs b/Adders.hs index e6676e9..d4dbbf8 100644 --- a/Adders.hs +++ b/Adders.hs @@ -53,7 +53,7 @@ instance Inv (BitVec D0) where -} -- Not really an adder either, but a slightly more complex example inv :: Bit -> Bit -inv a = hwnot a +inv a = let r = hwnot a in r -- Not really an adder either, but a slightly more complex example invinv :: Bit -> Bit @@ -146,6 +146,35 @@ rec_adder ((a:as), (b:bs)) = (rest, cin) = rec_adder (as, bs) (s, cout) = full_adder (a, b, cin) +foo = id +add, sub :: Int -> Int -> Int +add a b = a + b +sub a b = a - b + +highordtest = \x -> + let s = foo x + in + case s of + (a, b) -> + case a of + High -> add + Low -> let + op' = case b of + High -> sub + Low -> \c d -> c + in + \c d -> op' d c + +highordtest2 = \a b -> + case a of + High -> \c d -> d + Low -> let + op' :: Bit -> Bit -> Bit + op' = case b of + High -> \c d -> d + Low -> \c d -> c + in + \c d -> op' d c -- Four bit adder, using the continous adder below -- [a] -> [b] -> ([s], cout) --con_adder_4 as bs =