Expect that we have a relation with four combinations of logical values:
logic: ╭─────────────┬─────────────╮ │ a (boolean) │ b (boolean) │ ├─────────────┼─────────────┤ │ true │ true │ │ true │ false │ │ false │ true │ │ false │ false │ ╰─────────────┴─────────────╯ Record count: 4
we can use logical operators and functions:
relpipe-in-cli \
generate logic 2 \
a boolean \
b boolean \
true true \
true false \
false true \
false false \
| relpipe-tr-awk \
--relation '.*' \
--output-attribute AND boolean \
--output-attribute OR boolean \
--output-attribute XOR boolean \
--input-attributes-prepend \
--for-each '{ AND = a && b; OR = a || b; XOR = xor(a,b); record(); }' \
| relpipe-out-tabular
and append their results to the relation as additional attributes:
logic: ╭─────────────┬─────────────┬───────────────┬──────────────┬───────────────╮ │ a (boolean) │ b (boolean) │ AND (boolean) │ OR (boolean) │ XOR (boolean) │ ├─────────────┼─────────────┼───────────────┼──────────────┼───────────────┤ │ true │ true │ true │ true │ false │ │ true │ false │ false │ true │ true │ │ false │ true │ false │ true │ true │ │ false │ false │ false │ false │ false │ ╰─────────────┴─────────────┴───────────────┴──────────────┴───────────────╯ Record count: 4
Relational pipes, open standard and free software © 2018-2022 GlobalCode