Ternary logic: Difference between revisions

Content added Content deleted
(Add link to application)
Line 3,464:
=={{header|langur}}==
{{trans|Go}}
{{works with|langur|0.6.12}}
 
<syntaxhighlight lang="langur"># borrowing null for "maybe"
val .trSet = [false, null, true]
 
val .andresult = f given$"\{nn [.ar, .b {"maybe"]:-5}"
 
val .and = f switch[and] .a, .b {
case true, null:
case null, true:
Line 3,476:
}
 
val .or = f givenswitch[and] .a, .b {
case false, null:
case null, false:
Line 3,484:
 
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"
for .a in .trSet {
writeln $"\.a:result(.F;a), \" ", .result(not? .a:.F)"
}
 
Line 3,498 ⟶ 3,493:
for .a in .trSet {
for .b in .trSet {
writeln $"\.a:result(.Fa); \.b:result(.Fb); \", .result(.and(.a, .b):.F;")
}
}
Line 3,505 ⟶ 3,500:
for .a in .trSet {
for .b in .trSet {
writeln $"\.a:result(.Fa); \.b:result(.Fb); \", .result(.or(.a, .b):.F;")
}
}
Line 3,512 ⟶ 3,507:
for .a in .trSet {
for .b in .trSet {
writeln $"\.a:result(.Fa); \.b:result(.Fb); \", .result(.imply(.a, .b):.F;")
}
}
Line 3,519 ⟶ 3,514:
for .a in .trSet {
for .b in .trSet {
writeln $"\.a:result(.Fa); \.b:result(.Fb); \", .result(.a ==? .b:.F;")
}
}</syntaxhighlight>