summaryrefslogtreecommitdiff
path: root/46-50/46.hs
diff options
context:
space:
mode:
Diffstat (limited to '46-50/46.hs')
-rw-r--r--46-50/46.hs25
1 files changed, 25 insertions, 0 deletions
diff --git a/46-50/46.hs b/46-50/46.hs
new file mode 100644
index 0000000..30602e0
--- /dev/null
+++ b/46-50/46.hs
@@ -0,0 +1,25 @@
+and', or', nand', nor', xor', impl', equ' :: Bool -> Bool -> Bool
+not' :: Bool -> Bool
+
+not' True = False
+not' False = True
+
+and' True True = True
+and' _ _ = False
+
+or' False False = False
+or' _ _ = True
+
+xor' True False = True
+xor' False True = True
+xor' _ _ = False
+
+equ' a b = (not' a) `xor'` b
+impl' a b = (not' a) `or'` b
+
+nand' a = not' . and' a
+nor' a = not' . or' a
+
+table :: (Bool -> Bool -> Bool) -> IO ()
+table f = mapM_ putStrLn [show a ++ " " ++ show b ++ " " ++ (show $ f a b)
+ | let bin = [True, False], a <- bin, b <- bin]