RosettaCodeData/Task/Logical-operations/Phix/logical-operations-1.phix
2016-12-05 23:44:36 +01:00

25 lines
708 B
Text

--constant TRUE = (1=1), -- 1 internally \ now pre-
-- FALSE = not TRUE -- 0 internally / defined
type boolean(object b)
return integer(b) and find(b,{TRUE,FALSE})!=0
end type
function logicop(boolean a, boolean b)
return {a, b, a and b, a or b, not a, a xor b, a=b, a!=b}
end function
function TF(sequence tf)
boolean tfi
for i=1 to length(tf) do
tfi = tf[i]
tf[i] = iff(tfi?'T','F')
end for
return tf
end function
printf(1," a b and or not xor = !=\n")
for a=FALSE to TRUE do -- nb: TRUE to FALSE would need a "by -1".
for b=FALSE to TRUE do
printf(1,"%2c %2c %c %c %c %c %c %c\n",TF(logicop(a,b)))
end for
end for