Boolean data type has two possible truth values to represent logic.
Project description
Boolean data type has two possible truth values to represent logic.
📦 PyPi,
📰 Pdoc,
📘 Wiki.
Here is my implementation of digital logic gates in software. That includes
the basic gates not_, and_, or_, xor; their complements nand, nor,
xnor; and 2 propositional logic (taught in discrete mathematics) gates
imply, eq; and their complements nimply, neq. There is also a
multiplexer, called select, and a True
counter, called count. count
can help you make custom gates, such as an alternate concept of xnor
which returns True
only if all inputs are the same (standard xnor returns
True
if even inputs are True
). All of them can handle upto 8 inputs.
parse is influenced by "boolean" package, and is quite good at translating
str
to bool
. It can also handle double negatives, eg. not inactive
.
You know the and_ of 2-inputs, but what of 1-input? What of 0? And what of
the other gates? I answer them here.
Stability: Experimental.
from extra_boolean import *
parse("1")
parse("truthy")
parse("not off")
# True
parse("not true")
parse("inactive")
parse("disabled")
# False
imply(True, False)
# False
eq(False, False)
# True
xor(True, True, True)
# True
select(1, True, False, True)
# False ^
count(True, False, True)
# 2 ^ ^
Index
Name | Action |
---|---|
parse | Converts string to boolean. |
not_ | Checks if value is false. |
and_ | Checks if all values are true. |
or_ | Checks if any value is true. |
xor | Checks if odd no. of values are true. |
nand | Checks if any value is false. |
nor | Checks if all values are false. |
xnor | Checks if even no. of values are true. |
eq | Checks if antecedent ⇔ consequent (a ⇔ b). |
neq | Checks if antecedent ⇎ consequent (a ⇎ b). |
imply | Checks if antecedent ⇒ consequent (a ⇒ b). |
nimply | Checks if antecedent ⇏ consequent (a ⇏ b). |
select | Checks if ith value is true. |
count | Counts no. of true values. |
References
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for extra_boolean-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48df5b680367af5202d7a0473235c329c80f10cb3c23561bc01e5cf07e14ce67 |
|
MD5 | 852aaa075301f221405923ff4aa685d5 |
|
BLAKE2b-256 | 6cd6aa8540fe7b48703b75899e872a2f6e36949e3105ed4f3b9512cf6f91a668 |