Ternary logic: Difference between revisions
m
More consistent logical symbols in the test.
MazenMokhtar (talk | contribs) (Switch from custom values to Javascript native values (false, undefined, true) which leads to a more usable library. Fix an error with the test output for the NOT function.) |
MazenMokhtar (talk | contribs) m (More consistent logical symbols in the test.) |
||
Line 3,099:
nand = (a, b) => (a == false || b == false) ? true : (a == undefined || b == undefined) ? undefined : false
not = (a) => nand(a, a)
and = (a, b) => not(nand(a, b))
or = (a, b) => nand(not(a), not(b))
Line 3,110 ⟶ 3,109:
<syntaxhighlight lang="javascript">
trit = [false, undefined, true]
functor = {
display = {
log = 'NOT\n';
for (let a of trit) log += `${display.not}${display[a]} = ${display[not(a)]}\n`
log += '\
for (let a of trit) {
for (let b of trit) {
|