From 13c0046a6dbd41b15358e76856922144ac76e768 Mon Sep 17 00:00:00 2001 From: Joe Zhao Date: Sat, 4 Apr 2015 17:38:20 +0800 Subject: +46 +47 +48 +49 +50 --- H46.hs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 H46.hs (limited to 'H46.hs') diff --git a/H46.hs b/H46.hs new file mode 100644 index 0000000..41b56a2 --- /dev/null +++ b/H46.hs @@ -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]] -- cgit v1.2.3-70-g09d2