diff options
author | Determinant <[email protected]> | 2017-05-29 16:33:04 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2017-05-29 16:33:04 -0400 |
commit | d0aa856bedb0c0223b4ce2a67f5582b8eadf3682 (patch) | |
tree | 98d300c8cef2cc060dfdecd0e2de15575621cdc4 /46-50/47.hs | |
parent | 9db0008777cc4cd9f07e14a3458e3d903e3cc4f6 (diff) |
finish v5
Diffstat (limited to '46-50/47.hs')
-rw-r--r-- | 46-50/47.hs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/46-50/47.hs b/46-50/47.hs new file mode 100644 index 0000000..f672f4a --- /dev/null +++ b/46-50/47.hs @@ -0,0 +1,31 @@ +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 + +table2 :: (Bool -> Bool -> Bool) -> IO () +table2 f = mapM_ putStrLn [show a ++ " " ++ show b ++ " " ++ (show $ f a b) + | let bin = [True, False], a <- bin, b <- bin] + +infixl 4 `or'` +infixl 5 `xor'` +infixl 6 `and'` +infixl 7 `equ'` +-- use not for negation, it has fixity 9 by default |