Boolean data type has two possible truth values to represent logic.
Project description
Boolean data type has two possible truth values to represent logic.
:package: GoDev,
:newspaper: GoDoc,
:blue_book: 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
string
to boolean
. 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.
import (
boolean "github.com/golangf/extra-boolean"
)
boolean.Parse("1")
boolean.Parse("truthy")
boolean.Parse("not off")
// true
boolean.Parse("not true")
boolean.Parse("inactive")
boolean.Parse("disabled")
// false
boolean.Imply(true, false)
// false
boolean.Eq(false, false)
// true
boolean.Xor3(true, true, true)
// true
boolean.Select3(1, true, false, true)
// false ^
boolean.Count3(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
- GoDoc add newline character
- Indentation is replaced with tabs from spaces on save ...
- Testable Examples in Go
- Godoc: documenting Go code
- Optional Parameters in Go?
- Publishing Go Modules
- Developing and publishing modules
- Using Go Modules
- Naming Conventions in Go: Short but Descriptive
- Effective Go
- How to Write Go Code
- Batch Rename
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.1.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bcec407bf57806e7504bd5cf655b2bd84a79cf4951e25ee3072273297a4ea5ba |
|
MD5 | 4e56956d3491f84fed998ff088c45a96 |
|
BLAKE2b-256 | f281dfe1c3e24dafcfeea31654ab0b3b979ea0070972ff23ea6d6ebdedf95403 |