Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
25
Task/Logical-operations/Phix/logical-operations-1.phix
Normal file
25
Task/Logical-operations/Phix/logical-operations-1.phix
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
--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
|
||||
10
Task/Logical-operations/Phix/logical-operations-2.phix
Normal file
10
Task/Logical-operations/Phix/logical-operations-2.phix
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
function logiicop(integer a, integer b)
|
||||
return {a, b, a and b, a or b, not a, a xor b, a=b, a!=b}
|
||||
end function
|
||||
|
||||
printf(1," a b and or not xor = !=\n")
|
||||
for a=0 to 1 do
|
||||
for b=0 to 1 do
|
||||
printf(1,"%2d %2d %d %d %d %d %d %d\n",logiicop(a,b))
|
||||
end for
|
||||
end for
|
||||
Loading…
Add table
Add a link
Reference in a new issue