Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,6 @@
boolean a = true;
boolean b = false;
System.Debug('a AND b: ' + (a && b));
System.Debug('a OR b: ' + (a || b));
System.Debug('NOT a: ' + (!a));
System.Debug('a XOR b: ' + (a ^ b));

View file

@ -0,0 +1,7 @@
Lbl LOGIC
r₁→A
r₂→B
Disp "AND:",(A?B)▶Dec,i
Disp "OR:",(A??B)▶Dec,i
Disp "NOT:",(A?0,1)▶Dec,i
Return

View file

@ -0,0 +1,18 @@
LogicalOperations(BOOLEAN A,BOOLEAN B) := FUNCTION
ANDit := A AND B;
ORit := A OR B;
NOTA := NOT A;
XORit := (A OR B) AND NOT (A AND B);
DS := DATASET([{A,B,'A AND B is:',ANDit},
{A,B,'A OR B is:',ORit},
{A,B,'NOT A is:',NOTA},
{A,B,'A XOR B is:',XORit}],
{BOOLEAN AVal,BOOLEAN BVal,STRING11 valuetype,BOOLEAN val});
RETURN DS;
END;
LogicalOperations(FALSE,FALSE);
LogicalOperations(FALSE,TRUE);
LogicalOperations(TRUE,FALSE);
LogicalOperations(TRUE,TRUE);
LogicalOperations(1>2,1=1); //Boolean expressions are also valid here

View file

@ -0,0 +1,27 @@
' FB 1.05.0 Win64
Sub logicalDemo(b1 As Boolean, b2 As Boolean)
Print "b1 = "; b1
Print "b2 = "; b2
Print "b1 And b2 = "; b1 And b2
Print "b1 Or b2 = "; b1 Or b2
Print "b1 XOr b2 = "; b1 Xor b2
Print "b1 Eqv b2 = "; b1 Eqv b2
Print "b1 Imp b2 = "; b1 Imp b2
Print "Not b1 = "; Not b1
Print "b1 AndAlso b2 = "; b1 AndAlso b2
Print "b1 OrElse b2 = "; b1 OrElse b2
Print
End Sub
Dim b1 As Boolean = True
Dim b2 As Boolean = True
logicalDemo b1, b2
b2 = False
logicalDemo b1, b2
b1 = False
logicalDemo b1, b2
b2 = True
logicalDemo b1, b2
Print "Press any key to quit"
Sleep

View file

@ -0,0 +1,8 @@
def logical( a, b ) = println( """
a and b = ${a and b}
a or b = ${a or b}
not a = ${not a}
a xor b = ${a xor b}
""" )
for i <- [false, true], j <- [false, true] do logical( i, j )

View file

@ -0,0 +1,23 @@
include "ConsoleWindow"
def tab 6
dim as long a, b
print "In FB the Boolean constants _true = 1, _false = 0"
print string$( 39, "-" )
print " a", " b", "and", "or", "xor", "nand", "nor"
print string$( 39, "-" )
a = _false: b = _false: print a, b, a and b, a or b, a xor b, a nand b, a nor b
a = _false: b = _true: print a, b, a and b, a or b, a xor b, a nand b, a nor b
a = _true: b = _false: print a, b, a and b, a or b, a xor b, a nand b, a nor b
a = _true: b = _true: print a, b, a and b, a or b, a xor b, a nand b, a nor b
print
print "FB also has shorthand operator expressions:
print string$( 39, "-" )
print " a", " b", "&&", "||", "^^", "^&", "^|"
print string$( 39, "-" )
a = _false: b = _false: print a, b, a && b, a || b, a ^^ b, a ^& b, a ^| b
a = _false: b = _true: print a, b, a && b, a || b, a ^^ b, a ^& b, a ^| b
a = _true: b = _false: print a, b, a && b, a || b, a ^^ b, a ^& b, a ^| b
a = _true: b = _true: print a, b, a && b, a || b, a ^^ b, a ^& b, a ^| b

View file

@ -0,0 +1,6 @@
PROCEDURE Foo( a, b )
// a and b was defined as .F. (false) or .T. (true)
? a .AND. b
? a .OR. b
? ! a, ! b
RETURN

View file

@ -0,0 +1,15 @@
// br is just for formatting output here
define br => '\r'
// define vars
local(a = true, b = false)
// boolean comparators.
// note, not including comparison operators which would return boolean results
'a AND b: ' + (#a && #b)
br
'a OR b: ' + (#a || #b)
br
'NOT a: ' + !#a
br
'NOT a (using not): ' + not #a

View file

@ -0,0 +1,7 @@
function boolOps p1, p2
local boolOpsResult
put p1 && "AND" && p2 && "=" && merge("[[p1 and p2]]") & cr after boolOpsResult
put p1 && "OR" && p2 && "=" && merge("[[p1 or p2]]") & cr after boolOpsResult
put "NOT" && p1 && "=" && merge("[[not p1]]") & cr after boolOpsResult
return boolOpsResult
end boolOps

View file

@ -0,0 +1,22 @@
repeat for each item bop in "true,false"
put boolops(bop, bop) & cr after bopResult
put boolops(bop, not bop) & cr after bopResult
end repeat
put bopResult
-- results
true AND true = true
true OR true = true
NOT true = false
true AND false = false
true OR false = true
NOT true = false
false AND false = false
false OR false = false
NOT false = true
false AND true = false
false OR true = true
NOT false = true

View file

@ -0,0 +1,5 @@
proc logic(a, b) =
echo "a and b: ", a and b
echo "a or b: ", a or b
echo "not a: ", not a
echo "a xor b: ", a xor b

View file

@ -0,0 +1,5 @@
: logical(b1, b2)
System.Out "and = " << b1 b2 and << cr
System.Out "or = " << b1 b2 or << cr
System.Out "xor = " << b1 b2 xor << cr
System.Out "not = " << b1 not << cr ;

View 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

View 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

View file

@ -0,0 +1,6 @@
x = true
y = false
see "x and y = " + (x and y) + nl
see "x or y = " + (x or y) + nl
see "not x = " + (not x) + nl

View file

@ -0,0 +1,8 @@
func logic(a, b) {
say ("a and b: ", a && b);
say ("a or b: ", a || b);
say ("a xor b: ", a ^ b);
say (" not a: ", !a);
}
logic(false, true);

View file

@ -0,0 +1,11 @@
!logic:
(a? b?)
[
println("a and b: " a and b)
println("a or b: " a or b)
println("not a: " not a)
println("a xor b: " a xor b)
println("a nand b: " a nand b)
println("a nor b: " a nor b)
println("a not xor b: " a nxor b)
]

View file

@ -0,0 +1 @@
logic(true false)

View file

@ -0,0 +1,5 @@
func logic(a: Bool, b: Bool) {
println("a AND b: \(a && b)");
println("a OR b: \(a || b)");
println("NOT a: \(!a)");
}

View file

@ -0,0 +1,4 @@
(defun logical-functions (a b)
(print `(a and b = ,(and a b)))
(print `(a or b = ,(or a b)))
(print `(not a = ,(not a))) )

View file

@ -0,0 +1,5 @@
def logic(a; b):
"\(a) and \(b) => \(a and b)",
"\(a) or \(b) => \(a or b)",
"\(a) | not => \(a | not)",
"if \(a) then true else false end => \(if a then true else false end)" ;

View file

@ -0,0 +1,3 @@
(false, null, []) as $a
| (false, null, {}) as $b
| logic( $a; $b )

View file

@ -0,0 +1,37 @@
$ jq -n -r -f logical_operations.jq
false and false => false
false or false => false
false | not => true
if false then true else false end => false
false and null => false
false or null => false
false | not => true
if false then true else false end => false
false and {} => false
false or {} => true
false | not => true
if false then true else false end => false
null and false => false
null or false => false
null | not => true
if null then true else false end => false
null and null => false
null or null => false
null | not => true
if null then true else false end => false
null and {} => false
null or {} => true
null | not => true
if null then true else false end => false
[] and false => false
[] or false => true
[] | not => false
if [] then true else false end => true
[] and null => false
[] or null => true
[] | not => false
if [] then true else false end => true
[] and {} => true
[] or {} => true
[] | not => false
if [] then true else false end => true