Problem 47 Solutions

Solution 1

-- True if and only if a and b are true
(.&) : Bool -> Bool -> Bool
(.&) a b =
    a && b


-- True if either a or b are true
(.|) : Bool -> Bool -> Bool
(.|) a b =
  a || b


-- True either a or b are false
(/&) : Bool -> Bool -> Bool
(/&) a b =
    not (a && b)


-- True if and only if a and b are false
(/|) : Bool -> Bool -> Bool
(/|) a b =
    not (a || b)


-- True if a or b is true, but not if both are true
(*|) : Bool -> Bool -> Bool
(*|) a b =
      not (a == b) 


-- True if a is false or b is true
(.^) : Bool -> Bool -> Bool
(.^) a b =
      if a then b else True


-- True if both a and b are true, or both a and b ar false
(.=) : Bool -> Bool -> Bool
(.=) a b =
      a == b


truthTable : (Bool -> Bool -> Bool) -> List (Bool, Bool, Bool)
truthTable f = 
    -- your implementation goes here
    [ (True, True, f True True)
    , (True, False, f True False)
    , (False, True, f False True)
    , (False, False, f False False)
    ]

Back to problem

results matching ""

    No results matching ""