-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Patrick McElhaney
committed
Aug 3, 2019
1 parent
a7c21d5
commit 19a827f
Showing
3 changed files
with
63 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
const Boolio = require("./Boolio"); | ||
const AsciiTable = require("ascii-table"); | ||
const table = require("table").table; | ||
|
||
const expression = process.argv[2]; | ||
|
||
const truthTable = new Boolio(expression).truthTable(); | ||
|
||
const asciiTable = AsciiTable.factory({ | ||
heading: [...truthTable.atoms, " = "], | ||
rows: truthTable.rows.map(cols => cols.map(cell => (cell ? "T" : "F"))) | ||
}); | ||
|
||
for (let i = 0; i <= truthTable.atoms.length; i++) { | ||
asciiTable.setAlign(i, AsciiTable.CENTER); | ||
} | ||
|
||
console.log(expression); | ||
console.log(asciiTable.toString()); | ||
console.log( | ||
table( | ||
[ | ||
[...truthTable.atoms, "="], | ||
...truthTable.rows.map(row => row.map(cell => (cell ? "T" : "F"))) | ||
], | ||
{ | ||
columns: new Array(4).fill({ | ||
width: 10, | ||
alignment: "center" | ||
}) | ||
} | ||
) | ||
); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,6 @@ | |
}, | ||
"dependencies": { | ||
"acorn": "^6.2.1", | ||
"ascii-table": "0.0.9" | ||
"table": "^5.4.5" | ||
} | ||
} |