June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,12 @@
import extensions.
program =
[
bool a := true.
bool b := false.
console printLine("a and b is ", a && b).
console printLine("a or b is ", a || b).
console printLine("Not a is ", a inverted).
console printLine("a xor b is ", a ^^ b).
].

View file

@ -4,3 +4,6 @@ b = True
a_and_b = a && b
a_or_b = a || b
not_a = not a
a_xor_b = a /= b
a_nxor_b = a == b
a_implies_b = a <= b -- sic!

View file

@ -0,0 +1,8 @@
*Main > False && undefined
False
Prelude> undefined && False
*** Exception: Prelude.undefined
Prelude> True || undefined
True
Prelude> undefined || True
*** Exception: Prelude.undefined

View file

@ -0,0 +1,8 @@
Prelude> False <= undefined
*** Exception: Prelude.undefined
Prelude> undefined <= True
*** Exception: Prelude.undefined
Prelude> True < undefined
*** Exception: Prelude.undefined
Prelude> undefined < False
*** Exception: Prelude.undefined

View file

@ -0,0 +1,7 @@
U0 PrintLogic(Bool a, Bool b) {
Print("a and b is %d\n", a && b);
Print("a or b is %d\n", a || b);
Print("not a is %d\n", !a);
}
PrintLogic(TRUE, FALSE);

View file

@ -0,0 +1,24 @@
MODULE LogicalOps;
FROM FormatString IMPORT FormatString;
FROM Terminal IMPORT WriteString,WriteLn,ReadChar;
PROCEDURE Print(a,b : BOOLEAN);
VAR buf : ARRAY[0..31] OF CHAR;
BEGIN
FormatString("a and b is %b\n", buf, a AND b);
WriteString(buf);
FormatString("a or b is %b\n", buf, a OR b);
WriteString(buf);
FormatString("not a is %b\n", buf, NOT a);
WriteString(buf);
WriteLn
END Print;
BEGIN
Print(FALSE, FALSE);
Print(FALSE, TRUE);
Print(TRUE, TRUE);
Print(TRUE, FALSE);
ReadChar
END LogicalOps.

View file

@ -0,0 +1,26 @@
/*REXX program demonstrates some binary (also known as bit or logical) operations.*/
x= 1 ; y= 0 /*set the initial values of X and Y. */
@x= ' x '; @y= ' y ' /*define a couple of literals for HDRs.*/
/* [↓] echo the X and Y values.*/
call $ 'name', "value" /*display the header (title) line. */
call $ 'x' , x /*display "x" and then the value of X.*/
call $ 'y' , y /* " "y" " " " " " Y */
/* [↓] negate the X; then the Y value.*/
call $ 'name', "negated" /*some REXXes support the ¬ character*/
call $ 'x' , \x /*display "x" and then the value of ¬X*/
call $ 'y' , \y /* " "y" " " " " " ¬Y*/
say
say
call $ @x, @y, 'AND'; do x=0 to 1; do y=0 to 1; call $ x, y, x & y; end; end
call $ @x, @y, 'OR' ; do x=0 to 1; do y=0 to 1; call $ x, y, x | y; end; end
call $ @x, @y, 'XOR'; do x=0 to 1; do y=0 to 1; call $ x, y, x && y; end; end
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
$: parse arg @.1, @.2, @.3, @.4; hdr= length(@.1) \== 1; if hdr then say
do j=0 to hdr; _=
do k=1 for arg(); _=_ center(@.k, 7)
end /*k*/
say _
@.=copies('', 7) /*define a new header separator line. */
end /*j*/
return

View file

@ -0,0 +1,29 @@
/*REXX pgm demonstrates some binary (also known as bit or logical) extended operations.*/
x= 1 ; y= 0 /*set the initial values of X and Y. */
@x= ' x '; @y= ' y ' /*define a couple of literals for HDRs.*/
/* [↓] echo the X and Y values.*/
call $ 'name', "value" /*display the header (title) line. */
call $ 'x' , x /*display "x" and then the value of X.*/
call $ 'y' , y /* " "y" " " " " " Y */
/* [↓] negate the X; then the Y value.*/
call $ 'name', "negated" /*some REXXes support the ¬ character*/
call $ 'x' , \x /*display "x" and then the value of ¬X*/
call $ 'y' , \y /* " "y" " " " " " ¬Y*/
say /*note: NXOR is also known as XNOR. */
say /*all 16 bit operations could be shown.*/
call $ @x, @y, 'AND' ; do x=0 to 1; do y=0 to 1; call $ x, y, x & y ; end; end
call $ @x, @y, 'NAND'; do x=0 to 1; do y=0 to 1; call $ x, y, \(x & y); end; end
call $ @x, @y, 'OR' ; do x=0 to 1; do y=0 to 1; call $ x, y, x | y ; end; end
call $ @x, @y, 'NOR' ; do x=0 to 1; do y=0 to 1; call $ x, y, \(x | y); end; end
call $ @x, @y, 'XOR' ; do x=0 to 1; do y=0 to 1; call $ x, y, x && y ; end; end
call $ @x, @y, 'NXOR'; do x=0 to 1; do y=0 to 1; call $ x, y, \(x && y); end; end
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
$: parse arg @.1, @.2, @.3, @.4; hdr= length(@.1) \== 1; if hdr then say
do j=0 to hdr; _=
do k=1 for arg(); _=_ center(@.k, 7)
end /*k*/
say _
@.= copies('', 7) /*define a new separator (header) line.*/
end /*j*/
return

View file

@ -1,27 +0,0 @@
/*REXX program demonstrates some binary (also known as bit or logical) operations.*/
x=1; y=0; @v= 'value' /*set initial values of X & Y; literal.*/
/* [↓] echo the X and Y values.*/
call TT 'name', "value" /*display the header (title) line. */
call TT 'x' , x /*display "x" and then the value of X.*/
call TT 'y' , y /* " "y" " " " " " Y */
/* [↓] negate the X; then the Y value.*/
call TT 'name', "negated" /*some REXXes support the ¬ character*/
call TT 'x' , \x /*display "x" and then the value of ¬X*/
call TT 'y' , \y /* " "y" " " " " " ¬Y*/
/*both DO loops use 0 and 1 for values.*/
call TT @v, @v, 'AND'; do x=0 for 2; do y=0 for 2; call TT x, y, x & y; end /*y*/
end /*x*/
call TT @v, @v, 'OR'; do x=0 for 2; do y=0 for 2; call TT x, y, x | y; end /*y*/
end /*x*/
call TT @v, @v, 'XOR'; do x=0 for 2; do y=0 for 2; call TT x, y, x && y; end /*y*/
end /*x*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
TT: parse arg @.1,@.2,@.3,@.4; hdr=length(@.1)\==1; if hdr then say; w=7
do j=0 to hdr; _=; do k=1 for arg(); _=_ center(@.k,w); end /*k*/
say _
@.=copies('', w) /*define the header separator line. */
end /*j*/ /*W: is used for the width of a column*/
return