Skip to content

Instantly share code, notes, and snippets.

@sielicki
Created October 2, 2018 16:27
Show Gist options
  • Save sielicki/d67b06ade78a8572148f34a8a7daf990 to your computer and use it in GitHub Desktop.
Save sielicki/d67b06ade78a8572148f34a8a7daf990 to your computer and use it in GitHub Desktop.
Table of a boolean function`
results = [["X", "Y", "Z", "F"]];
Array.from({ length: 8 }, (_, k) => k).map(x => x.toString(2)
.padStart(3, 0))
.map(x => x.split(""))
.map(x => x.map(y => Boolean(parseInt(y))))
.map(x => function(a,b,c) {
results.push([a,b,c,
(
// Put your own F here
(x, y, z) => (
x && y && z
)
).apply(null, Array.prototype.slice.call(arguments))]);
}(...x));
console.table(results);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment