https://github.com/programarivm/truth-table
Data structure representing a logical truth table.
https://github.com/programarivm/truth-table
binary boolean false logic table ternary three true truth
Last synced: 7 months ago
JSON representation
Data structure representing a logical truth table.
- Host: GitHub
- URL: https://github.com/programarivm/truth-table
- Owner: programarivm
- Created: 2020-09-27T12:51:51.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-29T16:50:15.000Z (about 5 years ago)
- Last Synced: 2025-01-08T14:16:11.157Z (9 months ago)
- Topics: binary, boolean, false, logic, table, ternary, three, true, truth
- Language: PHP
- Homepage:
- Size: 33.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Truth Table
[](https://travis-ci.org/programarivm/truth-table)
[](https://www.gnu.org/licenses/gpl-3.0)
![]()
> A truth table is a mathematical table used in logic which sets out the functional values of logical expressions on each of their functional arguments. [Wikipedia](https://en.wikipedia.org/wiki/Truth_table).
### Install
Via composer:
$ composer require programarivm/truth-table
### Binary Table
Create a binary table with two input variables:
```php
use TruthTable\BinaryTable;$t = (new BinaryTable(2))->getTable();
```
Get the result of the table:
```php
use TruthTable\BinaryTable;$r = (new BinaryTable(2))->getResult();
```
Set specific indexes to `true` and get the result:
```php
use TruthTable\BinaryTable;$true = [0, 1];
$r = (new BinaryTable(2))
->setTrue($true)
->getResult();```
Set specific indexes to `false` and get the result:
```php
use TruthTable\BinaryTable;$false = [0, 1];
$r = (new BinaryTable(2))
->setFalse($false)
->getResult();```
### Ternary Table
Create a ternary table with two input variables:
```php
use TruthTable\TernaryTable;$t = (new TernaryTable(2))->getTable();
```
Get the result of the table:
```php
use TruthTable\TernaryTable;$r = (new TernaryTable(2))->getResult();
```
Set specific indexes to `true` and get the result:
```php
use TruthTable\TernaryTable;$true = [0, 1];
$r = (new TernaryTable(2))
->setTrue($true)
->getResult();```
Set specific indexes to `false` and get the result:
```php
use TruthTable\TernaryTable;$false = [0, 1];
$r = (new TernaryTable(2))
->setFalse($false)
->getResult();```
Set specific indexes to unknown and get the result:
```php
use TruthTable\TernaryTable;$unknown = [0, 1];
$r = (new TernaryTable(2))
->setUnknown($unknown)
->getResult();```
For further details please look at the [unit tests](https://github.com/programarivm/truth-table/tree/master/tests).
### License
The GNU General Public License.