Ternary logic: Difference between revisions

m
Re-alphabetized the entries
No edit summary
m (Re-alphabetized the entries)
Line 6,102:
 
 
=={{header|Yabasic}}==
{{trans|BASIC256}}
<lang yabasic>
tFalse = 0
tDontKnow = 1
tTrue = 2
 
sub not3(b)
return 2-b
end sub
 
sub and3(a,b)
return min(a,b)
end sub
 
sub or3(a,b)
return max(a,b)
end sub
 
sub eq3(a,b)
if a = tDontKnow or b = tDontKnow then
return tDontKnow
elsif a = b then
return tTrue
else
return tFalse
end if
end sub
 
sub xor3(a,b)
return not3(eq3(a,b))
end sub
 
sub shortName3$(i)
return mid$("F?T", i+1, 1)
end sub
 
sub longName3$(i)
switch i
case 1
return "Don't know"
case 2
return "True"
default
return "False"
end switch
end sub
 
print "Nombres cortos y largos para valores logicos ternarios:"
for i = tFalse to tTrue
print shortName3$(i), " ", longName3$(i)
next i
print
 
print "Funciones de parametro unico"
print "x", " ", "=x", " ", "not(x)"
for i = tFalse to tTrue
print shortName3$(i), " ", shortName3$(i), " ", shortName3$(not3(i))
next i
print
 
print "Funciones de doble parametro"
print "x"," ","y"," ","x AND y"," ","x OR y"," ","x EQ y"," ","x XOR y"
for a = tFalse to tTrue
for b = tFalse to tTrue
print shortName3$(a), " ", shortName3$(b), " ";
print shortName3$(and3(a,b)), " ", shortName3$(or3(a,b)), " ";
print shortName3$(eq3(a,b)), " ", shortName3$(xor3(a,b))
next b
next a
end
</lang>
{{out}}
<pre>
Igual que la entrada de Liberty BASIC.
</pre>
 
=={{header|Wren}}==
Line 6,275 ⟶ 6,200:
M | M M M
F | F M T
</pre>
 
=={{header|Yabasic}}==
{{trans|BASIC256}}
<lang yabasic>
tFalse = 0
tDontKnow = 1
tTrue = 2
 
sub not3(b)
return 2-b
end sub
 
sub and3(a,b)
return min(a,b)
end sub
 
sub or3(a,b)
return max(a,b)
end sub
 
sub eq3(a,b)
if a = tDontKnow or b = tDontKnow then
return tDontKnow
elsif a = b then
return tTrue
else
return tFalse
end if
end sub
 
sub xor3(a,b)
return not3(eq3(a,b))
end sub
 
sub shortName3$(i)
return mid$("F?T", i+1, 1)
end sub
 
sub longName3$(i)
switch i
case 1
return "Don't know"
case 2
return "True"
default
return "False"
end switch
end sub
 
print "Nombres cortos y largos para valores logicos ternarios:"
for i = tFalse to tTrue
print shortName3$(i), " ", longName3$(i)
next i
print
 
print "Funciones de parametro unico"
print "x", " ", "=x", " ", "not(x)"
for i = tFalse to tTrue
print shortName3$(i), " ", shortName3$(i), " ", shortName3$(not3(i))
next i
print
 
print "Funciones de doble parametro"
print "x"," ","y"," ","x AND y"," ","x OR y"," ","x EQ y"," ","x XOR y"
for a = tFalse to tTrue
for b = tFalse to tTrue
print shortName3$(a), " ", shortName3$(b), " ";
print shortName3$(and3(a,b)), " ", shortName3$(or3(a,b)), " ";
print shortName3$(eq3(a,b)), " ", shortName3$(xor3(a,b))
next b
next a
end
</lang>
{{out}}
<pre>
Igual que la entrada de Liberty BASIC.
</pre>
 
1,489

edits