diff options
Diffstat (limited to 'H46.hs')
-rw-r--r-- | H46.hs | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -0,0 +1,27 @@ +and',or',nand',nor',xor',impl',equ' :: Bool -> Bool -> Bool +not' :: Bool -> Bool + +not' True = False +not' _ = True + +and' True True = True +and' _ _ = False + +or' False False = False +or' _ _ = True + +nand' = curry $ not' . (uncurry and') + +nor' = curry $ not' . (uncurry or') + +xor' True True = False +xor' False False = False +xor' _ _ = True + +impl' a b = or' (not' a) b + +equ' = curry $ not' . (uncurry xor') + +table :: (Bool -> Bool -> Bool) -> IO () +table f = mapM_ putStrLn [show a ++ " " ++ show b ++ " " ++ show (f a b) + | a <- [True, False], b <- [True, False]] |