A Nim's Macro library
generates code to print bool truth table.
Macro-based means it can even be used at nim VM!
In heady:
dumpTable a^b # or `a ∧ b` (Unicode alternative)
Output:
a b a ^ b
0 0 0
0 1 0
1 0 0
1 1 1
What if want a html output as a string?
Here you are:
var s = "<ul>\n<li>"
strTable s, a^b, sep=" ", endl="</li>\n<li>"
s.setLen s.len-4
s.add "</ul>"
echo s
dumpTable: a ∧ (¬ b) ∨ c
Output:
a b c a ∧ (¬ b) ∨ c
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 0
1 1 1 1
As it's in Nim, you're free to use every Nim expression.
As it's done at compilation, nothing about secure problems
var cnt = 0
proc foo(a: bool): bool =
cnt.inc
a
dumpTableVars ¬ foo(a), [a]
echo cnt == 2