Ternary logic: Difference between revisions

→‎{{header|Yabasic}}: Corregido error en el código
(Ternary logic en TrueBASIC)
(→‎{{header|Yabasic}}: Corregido error en el código)
Line 6,037:
tDontKnow = 1
tTrue = 2
 
sub not3(b)
return 2-b
end sub
 
sub and3(a,b)
if a < b then return min(a else return ,b : fi)
end sub
 
sub or3(a,b)
if a > b then return max(a else return ,b : fi)
end sub
 
sub eq3(a,b)
if a = tDontKnow or b = tDontKnow then
switch a
case tDontKnow or b = return tDontKnow
elsif a = b then
return tDontKnow
return tTrue
case b
else
return tTrue
return tFalse
default
end if
return tFalse
end switch
end sub
 
sub xor3(a,b)
return not3(eq3(a,b))
end sub
 
sub not3(b)
return 2-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
Line 6,089 ⟶ 6,088:
print "x", " ", "=x", " ", "not(x)"
for i = tFalse to tTrue
print shortName3$(i), " ", shortName3$(i), " ", shortName3$(not3(i))
next i
print
Line 6,096 ⟶ 6,095:
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
Line 6,108 ⟶ 6,107:
Igual que la entrada de Liberty BASIC.
</pre>
 
 
=={{header|Wren}}==
2,122

edits