Write a program that reads several boolean operations and prints their result.
Input will consist of several lines each containing
a boolean operation.
This operation may be unary, in this case
the input line will contain the word not
followed by a boolean p.
This operation may be binary, in this case
the input line will contain a boolean p, an operator x and a boolean q.
Input tokens are separated by a single space.
Booleans p and q are either of the strings true
or false
and the operator x is either of the strings and
, or
, xor
or implies
.
Output should contain a line with the result of the given input operation.
Example input
true and false
false or true
not true
true xor true
true implies true
Example output
false
true
false
false
true
try first: bool-and-or bool-not
try next: set-member
Copyright © 2020-2022 Rudy Matela
This text is available under the CC BY-SA 4.0 license.
Originally available on cscx.org/bool-calc