RosettaCodeData/Task/Ternary-logic/BASIC256/ternary-logic.basic
2023-07-01 13:44:08 -04:00

70 lines
1.4 KiB
Text

global tFalse, tDontKnow, tTrue
tFalse = 0
tDontKnow = 1
tTrue = 2
print "Nombres cortos y largos para valores lógicos ternarios:"
for i = tFalse to tTrue
print shortName3$(i); " "; longName3$(i)
next i
print
print "Funciones de parámetro único"
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 parámetro"
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
function and3(a,b)
if a < b then return a else return b
end function
function or3(a,b)
if a > b then return a else return b
end function
function eq3(a,b)
begin case
case a = tDontKnow or b = tDontKnow
return tDontKnow
case a = b
return tTrue
else
return tFalse
end case
end function
function xor3(a,b)
return not3(eq3(a,b))
end function
function not3(b)
return 2-b
end function
function shortName3$(i)
return mid("F?T", i+1, 1)
end function
function longName3$(i)
begin case
case i = 1
return "Don't know"
case i = 2
return "True"
else
return "False"
end case
end function