From: Matthijs Kooijman Date: Thu, 29 Jan 2009 16:43:10 +0000 (+0100) Subject: Make full_adder simpler. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=1e7d79de8b34aca4bf0f63d3822dd0b018356038;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Make full_adder simpler. --- diff --git a/Adders.hs b/Adders.hs index 03f0410..71d38dc 100644 --- a/Adders.hs +++ b/Adders.hs @@ -42,8 +42,9 @@ half_adder (a, b) = full_adder :: (Bit, Bit, Bit) -> (Bit, Bit) full_adder (a, b, cin) = (s, c) where - s = a `hwxor` b `hwxor` cin - c = a `hwand` b `hwor` (cin `hwand` (a `hwxor` b)) + x = a `hwxor` b + s = x `hwxor` cin + c = a `hwand` b `hwor` (cin `hwand` x) -- Four bit adder -- Explicit version