Skip to content

KiritoEM/boolean-table

Repository files navigation

⚑ Boolean Table

A simple tool to generate a truth table from Boolean expressions.

πŸ“¦ Installation

With npm:

npm i -g simple-boolean-table

Or by cloning the repository( but first install Bun on your OS):

git clone https://github.com/KiritoEM/boolean-table
cd boolean-table
bun install

πŸš€ Usage

To start the tool, run:

boolean-table

Or use the tool locally by linking the project:

bun link
boolean-table

πŸš€ Scripts

  • link : Link the project
  • test: Run test unit
bun run link #Link the project
bun run test  #Run tests

βœ… Supported Expressions:

  • a-z or A-Z : Variables
  • & : AND
  • ~ : NOT
  • | : OR
  • == : EQUAL
  • -> : IMPLIES

πŸ”§ Commands:

  • expression <expression> : Generates the truth table for the given expression.
  • expression <expression> --step : Generates the truth table by printing subexpressions
  • help : Displays the help screen.

πŸ“Œ Example Usage

boolean-table expression "(a -> ~b) == (b | a)"

# Truth table for (a -> ~b) == (b | a)
| a | b | (a -> ~b) == (b | a) |
|---|---|----------------------|
| 0 | 0 | 0                    |
| 0 | 1 | 1                    |
| 1 | 0 | 1                    |
| 1 | 1 | 0                    |

Or by printing subexpressions:

boolean-table expression "(a -> ~b) == (b | a)" --step

# Truth table for (a -> ~b) == (b | a) by printing subexpressions
 | a    | b    | ~b    | (a -> ~b) | (b | a) | (a -> ~b) == (b | a) |
 |------|------|-------|-----------|---------|----------------------|
 | 0    | 0    | 1     | 1         | 0       | 0                    |
 | 0    | 1    | 0     | 1         | 1       | 1                    |
 | 1    | 0    | 1     | 1         | 1       | 1                    |
 | 1    | 1    | 0     | 0         | 1       | 0                    |

About

A tool to generate a truth table via expressions developed with Bun

Resources

Stars

Watchers

Forks

Packages

No packages published