Ternary logic: Difference between revisions
Content added Content deleted
(Add link to application) |
Langurmonkey (talk | contribs) |
||
Line 3,464: | Line 3,464: | ||
=={{header|langur}}== |
=={{header|langur}}== |
||
{{trans|Go}} |
{{trans|Go}} |
||
{{works with|langur|0.6.12}} |
|||
<syntaxhighlight lang="langur"># borrowing null for "maybe" |
<syntaxhighlight lang="langur"># borrowing null for "maybe" |
||
val .trSet = [false, null, true] |
val .trSet = [false, null, true] |
||
val . |
val .result = f $"\{nn [.r, "maybe"]:-5}" |
||
val .and = f switch[and] .a, .b { |
|||
case true, null: |
case true, null: |
||
case null, true: |
case null, true: |
||
Line 3,476: | Line 3,476: | ||
} |
} |
||
val .or = f |
val .or = f switch[and] .a, .b { |
||
case false, null: |
case false, null: |
||
case null, false: |
case null, false: |
||
Line 3,484: | Line 3,484: | ||
val .imply = f if(.a nor .b: not? .a; .b) |
val .imply = f if(.a nor .b: not? .a; .b) |
||
# formatting function for the result values |
|||
# replacing null with "maybe" |
|||
# using left alignment of 5 code points |
|||
val .F = f $"\{nn [.r, "maybe"]:-5}" |
|||
writeln "a not a" |
writeln "a not a" |
||
for .a in .trSet { |
for .a in .trSet { |
||
writeln |
writeln .result(.a), " ", .result(not? .a) |
||
} |
} |
||
Line 3,498: | Line 3,493: | ||
for .a in .trSet { |
for .a in .trSet { |
||
for .b in .trSet { |
for .b in .trSet { |
||
writeln $"\. |
writeln $"\.result(.a); \.result(.b); ", .result(.and(.a, .b)) |
||
} |
} |
||
} |
} |
||
Line 3,505: | Line 3,500: | ||
for .a in .trSet { |
for .a in .trSet { |
||
for .b in .trSet { |
for .b in .trSet { |
||
writeln $"\. |
writeln $"\.result(.a); \.result(.b); ", .result(.or(.a, .b)) |
||
} |
} |
||
} |
} |
||
Line 3,512: | Line 3,507: | ||
for .a in .trSet { |
for .a in .trSet { |
||
for .b in .trSet { |
for .b in .trSet { |
||
writeln $"\. |
writeln $"\.result(.a); \.result(.b); ", .result(.imply(.a, .b)) |
||
} |
} |
||
} |
} |
||
Line 3,519: | Line 3,514: | ||
for .a in .trSet { |
for .a in .trSet { |
||
for .b in .trSet { |
for .b in .trSet { |
||
writeln $"\. |
writeln $"\.result(.a); \.result(.b); ", .result(.a ==? .b) |
||
} |
} |
||
}</syntaxhighlight> |
}</syntaxhighlight> |