blob: 44a62a98feac19510dd4150b569a9aa4034109d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
module H47 where
-- Any that lacks a infix precedence declaration will assume 9
infixl 4 `or'`
infixl 4 `nor'`
infixl 5 `xor'`
infixl 6 `and'`
infixl 6 `nand'`
infixl 3 `equ'`
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]]
|