# Problem 47

Create custom infix operators for the logical functions from Problem 46. Use the following operator tokens to replace the functions in Problem 46.

``````.& = and_
.| = or_
/& = nand_
/| = nor_
*| for xor_
.^ for implies
.= for equivalent
``````

Precedence and associativity of custom operators can be set with the keywords infixl, infix, and infixr. See http://elm-lang.org/blog/announce/0.10#infix-operators.

## Example

``````truthTable (\a b -> a .& ( a .| b)) ==
[ (True, True, True)
, (True, False, True)
, (False, True, False)
, (False, False, False)
]
{--
a=True  b=True  True
a=True  b=False True
a=False b=True  False
a=False b=False False
--}
``````

## Unit Test

``````import Html exposing (text)
import List exposing (map)

truthTable : (Bool -> Bool -> Bool) -> List (Bool, Bool, Bool)
truthTable f =
List.repeat 4 (True, True, f True True)

main =
text
(if (test) then
else
"Your implementation failed at least one test."
)

test : Bool
test =
List.all ((==) True)
[ truthTable (.&) ==
[ (True, True, True)
, (True, False, False)
, (False, True, False)
, (False, False, False)
]
, truthTable (.|) ==
[ (True, True, True)
, (True, False, True)
, (False, True, True)
, (False, False, False)
]
, truthTable (/&) ==
[ (True, True, False)
, (True, False, True)
, (False, True, True)
, (False, False, True)
]
, truthTable (/|) ==
[ (True, True, False)
, (True, False, False)
, (False, True, False)
, (False, False, True)
]
, truthTable (*|) ==
[ (True, True, False)
, (True, False, True)
, (False, True, True)
, (False, False, False)
]
, truthTable (.^) ==
[ (True, True, True)
, (True, False, False)
, (False, True, True)
, (False, False, True)
]
, truthTable (.=) ==
[ (True, True, True)
, (True, False, False)
, (False, True, False)
, (False, False, True)
]
, truthTable (\a b -> ( a .& ( a .| b))) ==
[ (True, True, True)
, (True, False, True)
, (False, True, False)
, (False, False, False)
]
]
``````

Solutions