Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
category:
- Simple
from: http://rosettacode.org/wiki/Boolean_values
note: Basic language learning

View file

@ -0,0 +1,9 @@
;Task:
Show how to represent the boolean states "'''true'''" and "'''false'''" in a language.
If other objects represent "'''true'''" or "'''false'''" in conditionals, note it.
;Related tasks:
*   [[Logical operations]]
<br><br>

View file

@ -0,0 +1,2 @@
FALSE DC X'00'
TRUE DC X'FF'

View file

@ -0,0 +1,2 @@
clr bit ; clears
setb bit ; sets

View file

@ -0,0 +1,50 @@
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program boolean.s */
/*******************************************/
/* Constantes file */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"
.equ FALSE, 0 // or other value
.equ TRUE, 1 // or other value
/*******************************************/
/* Initialized data */
/*******************************************/
.data
szMessTrue: .asciz "The value is true.\n"
szMessFalse: .asciz "The value is false.\n"
/*******************************************/
/* UnInitialized data */
/*******************************************/
.bss
/*******************************************/
/* code section */
/*******************************************/
.text
.global main
main: // entry of program
mov x0,0
//mov x0,#1 //uncomment pour other test
cmp x0,TRUE
bne 1f
// value true
ldr x0,qAdrszMessTrue
bl affichageMess
b 100f
1: // value False
ldr x0,qAdrszMessFalse
bl affichageMess
100: // standard end of the program */
mov x0,0 // return code
mov x8,EXIT // request to exit program
svc 0 // perform the system call
qAdrszMessTrue: .quad szMessTrue
qAdrszMessFalse: .quad szMessFalse
/********************************************************/
/* File Include fonctions */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"

View file

@ -0,0 +1,30 @@
BOOL f = FALSE, t = TRUE;
[]BOOL ft = (f, t);
STRING or = " or ";
FOR key TO UPB ft DO
BOOL val = ft[key];
UNION(VOID, INT) void = (val|666|EMPTY);
REF STRING ref = (val|HEAP STRING|NIL);
INT int = ABS val;
REAL real = ABS val;
COMPL compl = ABS val;
BITS bits = BIN ABS val; # or bitspack(val); #
BYTES bytes = bytes pack((val|"?"|null char)*bytes width);
CHAR char = (val|"?"|null char);
STRING string = (val|"?"|"");
print((((val | "TRUE" | "FALSE" ), ": ", val, or, (val|flip|flop), new line)));
print((" void: ", " => ", (void|(VOID):FALSE|TRUE), new line));
print((" ref: ", " => ", ref ISNT REF STRING(NIL), new line));
print((" int: ", int , " => ", int /= 0, new line));
print((" real: ", real , " => ", real /= 0, new line));
print((" compl: ", compl , " => ", compl /= 0, new line));
print((" bits: ", bits , " => ", ABS bits /= 0, or, bits /= 2r0, or,
bits width ELEM bits, or, []BOOL(bits)[bits width], new line));
print((" bytes: """, STRING(bytes) , """ => ", 1 ELEM bytes /= null char, or,
STRING(bytes) /= null char*bytes width, or,
STRING(bytes)[1] /= null char, new line));
print((" char: """, char , """ => ", ABS char /= 0 , or, char /= null char, new line));
print(("string: """, string , """ => ", string /= "", or, UPB string /= 0, new line));
print((new line))
OD

View file

@ -0,0 +1,4 @@
1 ^ 1
1
1 ^ 0
0

View file

@ -0,0 +1,64 @@
/* ARM assembly Raspberry PI */
/* program areaString.s */
/* Constantes */
@ The are no TRUE or FALSE constants in ARM Assembly
.equ FALSE, 0 @ or other value
.equ TRUE, 1 @ or other value
.equ STDOUT, 1 @ Linux output console
.equ EXIT, 1 @ Linux syscall
.equ WRITE, 4 @ Linux syscall
/* Initialized data */
.data
szMessTrue: .asciz "The value is true.\n"
szMessFalse: .asciz "The value is false.\n"
/* UnInitialized data */
.bss
/* code section */
.text
.global main
main: /* entry of program */
push {fp,lr} /* saves 2 registers */
mov r0,#0
//mov r0,#1 @uncomment pour other test
cmp r0,#TRUE
bne 1f
@ value true
ldr r0,iAdrszMessTrue
bl affichageMess
b 100f
1: @ value False
ldr r0,iAdrszMessFalse
bl affichageMess
100: /* standard end of the program */
mov r0, #0 @ return code
pop {fp,lr} @restaur 2 registers
mov r7, #EXIT @ request to exit program
swi 0 @ perform the system call
iAdrszMessTrue: .int szMessTrue
iAdrszMessFalse: .int szMessFalse
/******************************************************************/
/* display text with size calculation */
/******************************************************************/
/* r0 contains the address of the message */
affichageMess:
push {fp,lr} /* save registres */
push {r0,r1,r2,r7} /* save others registers */
mov r2,#0 /* counter length */
1: /* loop length calculation */
ldrb r1,[r0,r2] /* read octet start position + index */
cmp r1,#0 /* if 0 its over */
addne r2,r2,#1 /* else add 1 in the length */
bne 1b /* and loop */
/* so here r2 contains the length of the message */
mov r1,r0 /* address message in r1 */
mov r0,#STDOUT /* code to write to the standard output Linux */
mov r7, #WRITE /* code call system "write" */
swi #0 /* call systeme */
pop {r0,r1,r2,r7} /* restaur others registers */
pop {fp,lr} /* restaur des 2 registres */
bx lr /* return */

View file

@ -0,0 +1,18 @@
BEGIN {
# Do not put quotes round the numeric values, or the tests will fail
a = 1 # True
b = 0 # False
# Boolean evaluations
if (a) { print "first test a is true" } # This should print
if (b) { print "second test b is true" } # This should not print
if (!a) { print "third test a is false" } # This should not print
if (!b) { print "forth test b is false" } # This should print
# Boolean evaluation using comparison against zero
if (a == 0) { print "fifth test a is false" } # This should not print
if (b == 0) { print "sixth test b is false" } # This should print
if (a != 0) { print "seventh test a is true" } # This should print
if (b != 0) { print "eighth test b is true" } # This should not print
}

View file

@ -0,0 +1,30 @@
PROC Test(BYTE v)
PrintF("Variable v has value %B%E",v)
IF v THEN
PrintE("Condition IF v is satisfied.")
ELSE
PrintE("Condition IF v is not satisfied.")
FI
IF v=0 THEN
PrintE("Condition IF v=0 is satisfied.")
ELSE
PrintE("Condition IF v=0 is not satisfied.")
FI
IF v<>0 THEN
PrintE("Condition IF v<>0 is satisfied.")
ELSE
PrintE("Condition IF v<>0 is not satisfied.")
FI
IF v#0 THEN
PrintE("Condition IF v#0 is satisfied.")
ELSE
PrintE("Condition IF v#0 is not satisfied.")
FI
PutE()
RETURN
PROC Main()
Test(0)
Test(1)
Test(86)
RETURN

View file

@ -0,0 +1 @@
type Boolean is (False, True);

View file

@ -0,0 +1,7 @@
1 > 2 --> false
not false --> true
{true as integer, false as integer, 1 as boolean, 0 as boolean}
--> {1, 0, true, false}
true = 1 --> false

View file

@ -0,0 +1,2 @@
{yes as boolean, no as boolean}
--> {true, false}

View file

@ -0,0 +1 @@
sortItems from L given reversal : true

View file

@ -0,0 +1 @@
sortItems from L with reversal

View file

@ -0,0 +1 @@
sortItems from L given reversal:yes

View file

@ -0,0 +1,3 @@
? 2 = 3
? 2 = 2
IF 7 THEN ?"HELLO"

View file

@ -0,0 +1,7 @@
a: true
b: false
if? a [ print "yep" ] else [ print "nope" ]
if? b -> print "nope"
else -> print "yep"

View file

@ -0,0 +1,11 @@
10 LET A%=0
20 LET B%=NOT(A%)
30 PRINT "THIS VERSION OF BASIC USES"
40 PRINT B%; " AS ITS TRUE VALUE"
50 IF A% THEN PRINT "TEST ONE DOES NOT PRINT"
60 IF B% THEN PRINT "TEST TWO DOES PRINT"
70 IF A%=0 THEN PRINT "TEST THREE (FALSE BY COMPARISON) DOES PRINT"
80 IF B%=0 THEN PRINT "TEST FOUR (FALSE BY COMPARISON) DOES NOT PRINT"
90 IF A%<>0 THEN PRINT "TEST FIVE (TRUE BY COMPARISON) DOES NOT PRINT"
100 IF B%<>0 THEN PRINT "TEST SIX (TRUE BY COMPARISON) DOES PRINT"
110 END

View file

@ -0,0 +1,7 @@
' BASIC256 used numbers to represent true and false
' values. Zero is false and anything else is true.
' The built in constants true and false exist
' and represent one and zero respectively.
print false
print true

View file

@ -0,0 +1,5 @@
REM BBC BASIC uses integers to represent Booleans; the keywords
REM FALSE and TRUE equate to 0 and -1 (&FFFFFFFF) respectively:
PRINT FALSE
PRINT TRUE

View file

@ -0,0 +1,8 @@
' Boolean TRUE and FALSE are non-zero and zero constants
a = TRUE
b = FALSE
PRINT a, ", ", b
IF 0 THEN PRINT "TRUE" : ELSE PRINT "FALSE"
IF 1 THEN PRINT "TRUE"
IF 2 THEN PRINT "TRUE"

View file

@ -0,0 +1,19 @@
@echo off
::true
set "a=x"
::false
set "b="
if defined a (
echo a is true
) else (
echo a is false
)
if defined b (
echo b is true
) else (
echo b is false
)
pause>nul

View file

@ -0,0 +1 @@
bool? value = null

View file

@ -0,0 +1,8 @@
foreach(var 1 42 ON yes True y Princess
0 OFF no False n Princess-NOTFOUND)
if(var)
message(STATUS "${var} is true.")
else()
message(STATUS "${var} is false.")
endif()
endforeach(var)

View file

@ -0,0 +1 @@
01 some-bool PIC 1 BIT.

View file

@ -0,0 +1,4 @@
01 X PIC 9.
88 X-Is-One VALUE 1.
88 X-Is-Even VALUE 0 2 4 6 8.
88 X-Larger-Than-5 VALUE 6 THRU 9.

View file

@ -0,0 +1,28 @@
PROGRAM-ID. Condition-Example.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Foo PIC 9 VALUE 5.
88 Is-Not-Zero VALUE 1 THRU 9
WHEN SET TO FALSE IS 0.
PROCEDURE DIVISION.
Main.
PERFORM Is-Foo-Zero
SET Is-Not-Zero TO FALSE
PERFORM Is-Foo-Zero
SET Is-Not-Zero TO TRUE
PERFORM Is-Foo-Zero
GOBACK
.
Is-Foo-Zero.
IF Is-Not-Zero
DISPLAY "Foo is not zero, it is " Foo "."
ELSE
DISPLAY "Foo is zero."
END-IF
.

View file

@ -0,0 +1 @@
::Bool = False | True

View file

@ -0,0 +1,28 @@
h1 = {foo: "bar"}
h2 = {foo: "bar"}
true_expressions = [
true
1
h1? # because h1 is defined above
not false
!false
[]
{}
1 + 1 == 2
1 == 1 # simple value equality
true or false
]
false_expressions = [
false
not true
undeclared_variable?
0
''
null
undefined
h1 == h2 # despite having same key/values
1 == "1" # different types
false and true
]

View file

@ -0,0 +1,11 @@
10 f%=("z"="a") : t%=not f% : rem capture a boolean evaluation
15 print chr$(147);chr$(14);
20 print "True is evaulated as:";t%
30 print "False is evaluated as:";f%
40 print:print "Any non-zero number will evaluate to"
50 print "true as shown in this example:":print
60 for i=-2 to 2
70 print i;" = ";
80 if i then print "True":goto 100
90 print "False"
100 next

View file

@ -0,0 +1,6 @@
VAR
b,c: BOOLEAN;
...
b := TRUE;
c := FALSE;
...

View file

@ -0,0 +1,9 @@
if false
puts "false"
elsif nil
puts "nil"
elsif Pointer(Nil).new 0
puts "null pointer"
elsif true && "any other value"
puts "finally true!"
end

View file

@ -0,0 +1,2 @@
#t // <boolean> true
#f // <boolean> false

View file

@ -0,0 +1,8 @@
? if (true) { "a" } else { "b" }
# value: "a"
? if (false) { "a" } else { "b" }
# value: "b"
? if (90) { "a" } else { "b" }
# problem: the int 90 doesn't coerce to a boolean

View file

@ -0,0 +1,7 @@
? def bowlian {
> to __conformTo(guard) {
> if (guard == boolean) { return true }
> }
> }
> if (bowlian) { "a" } else { "b" }
# value: "a"

View file

@ -0,0 +1,20 @@
myBool boolean = 0;
SysLib.writeStdout("myBool: " + StrLib.booleanAsString(myBool));
myBool = 1;
SysLib.writeStdout("myBool: " + StrLib.booleanAsString(myBool));
myBool = 2;
SysLib.writeStdout("myBool: " + StrLib.booleanAsString(myBool));
myBool = false;
SysLib.writeStdout("myBool: " + StrLib.booleanAsString(myBool));
myBool = true;
SysLib.writeStdout("myBool: " + StrLib.booleanAsString(myBool));
myInt int = 0;
SysLib.writeStdout("myInt: " + StrLib.booleanAsString(myInt));
myInt = 1;
SysLib.writeStdout("myInt: " + StrLib.booleanAsString(myInt));
myInt = 2;
SysLib.writeStdout("myInt: " + StrLib.booleanAsString(myInt));
myInt = false;
SysLib.writeStdout("myInt: " + StrLib.booleanAsString(myInt));
myInt = true;
SysLib.writeStdout("myInt: " + StrLib.booleanAsString(myInt));

View file

@ -0,0 +1,18 @@
^|EMal has a dedicated Logical type expressed by the logic keyword.
|It's not nullable and holds the two values false and true.
|There are no implicit conversions, but explicit conversions
|from/to int (0,1) or text ("⊥", "") are allowed.
|^
logic booleanTrue = true
logic booleanFalse = false
if 2 > 1 and true and not false
writeLine("true: " + true + ", false: " + false)
end
if false == logic!0
writeLine("explicit conversion from integer")
end
if true == logic!""
writeLine("explicit conversion from text")
end
writeLine(int!true) # is one
writeLine(text!false) # is "⊥"

View file

@ -0,0 +1,12 @@
boolNumber = 1
if boolNumber = 1
print "True"
else
print "False"
.
boolString$ = "true"
if boolString$ = "true"
print "True"
else
print "False"
.

View file

@ -0,0 +1,4 @@
(not #t) → #f
(not #f) → #t
(not null) → #f
(not 0) → #f

View file

@ -0,0 +1,18 @@
module GeorgeBoole {
@Inject Console console;
void run() {
Boolean f = False;
assert !f == True;
// methods like "and", "or", "xor", and "not" are the same as
// the operators "&"/"&&", "|"/"||", "^"/"^^", and the unary "~"
assert True.and(False) == True & False == False;
assert True.or(False) == True | False == True;
assert True.xor(False) == True ^ False == True;
assert True.not() == ~True == False;
console.print($"0==1 = {0==1}");
console.print($"!False = {!False}");
}
}

View file

@ -0,0 +1,6 @@
iex(1)> true === :true
true
iex(2)> false === :false
true
iex(3)> true === 1
false

View file

@ -0,0 +1,4 @@
iex(4)> nil === :nil
true
iex(5)> nil === false
false

View file

@ -0,0 +1,44 @@
--True and False directly represent Boolean values in Elm
--For eg to show yes for true and no for false
if True then "yes" else "no"
--Same expression differently
if False then "no" else "yes"
--This you can run as a program
--Elm allows you to take anything you want for representation
--In the program we take T for true F for false
import Html exposing(text,div,Html)
import Html.Attributes exposing(style)
type Expr = T | F | And Expr Expr | Or Expr Expr | Not Expr
evaluate : Expr->Bool
evaluate expression =
case expression of
T ->
True
F ->
False
And expr1 expr2 ->
evaluate expr1 && evaluate expr2
Or expr1 expr2 ->
evaluate expr1 || evaluate expr2
Not expr ->
not (evaluate expr)
--CHECKING RANDOM LOGICAL EXPRESSIONS
ex1= Not F
ex2= And T F
ex3= And (Not(Or T F)) T
main =
div [] (List.map display [ex1, ex2, ex3])
display expr=
div [] [ text ( toString expr ++ "-->" ++ toString(evaluate expr) ) ]
--END

View file

@ -0,0 +1,6 @@
1> 1 < 2.
true
2> 1 < 1.
false
3> 0 == false.
false

View file

@ -0,0 +1 @@
=AND(A1;B1)

View file

@ -0,0 +1,4 @@
0 0 FALSE
0 1 FALSE
1 0 FALSE
1 1 TRUE

View file

@ -0,0 +1 @@
type bool = System.Boolean

View file

@ -0,0 +1,2 @@
TRUE . \ -1
FALSE . \ 0

View file

@ -0,0 +1,5 @@
TYPE MIXED
LOGICAL*1 LIVE
REAL*8 VALUE
END TYPE MIXED
TYPE(MIXED) STUFF(100)

View file

@ -0,0 +1,5 @@
TYPE MIXED
LOGICAL*1 LIVE(100)
REAL*8 VALUE(100)
END TYPE MIXED
TYPE(MIXED) STUFF

View file

@ -0,0 +1,23 @@
{$mode objfpc}{$ifdef mswindows}{$apptype console}{$endif}
const
true = 'true';
false = 'false';
begin
writeln(true);
writeln(false);
end.
[ EDIT ]
See https://wiki.freepascal.org/Boolean
While you can assign values to true and false, it has now nothing to do with the boolean values....
Try with this function:
FUNCTION IsNatural ( CONST num: VARIANT ): BOOLEAN;
BEGIN
IsNatural := ( num > 0 );
END;

View file

@ -0,0 +1,14 @@
' FB 1.05.0 Win64
Dim i As Integer = 23
Dim s As String = "False"
Dim b As Boolean
b = i
Print b
b = CBool(s)
Print b
i = b
Print i
i = CInt(true)
Print i
Sleep

View file

@ -0,0 +1,5 @@
window 1
BOOL boolTest
boolTest = -1
print boolTest
HandleEvents

View file

@ -0,0 +1 @@
implicit conversion from constant value -1 to 'BOOL'; the only well defined values for 'BOOL' are YES and NO [-Wobjc-bool-constant-conversion]

View file

@ -0,0 +1,42 @@
void local fn BooleanExercise
BOOL areEqual = (1 == 1) // areEqual is YES
BOOL areNotEqual = not areEqual /* areNotEqual is converted to: areEqual = (-(1 == 1)). -1 throws a clang warning.
NOTE: FB does not accept the "!" shorthand for "not", i.e. !areEqual, common in other languages. */
print "areEqual == "; areEqual
print "areNotEqual == "; areNotEqual
print
// Boolean types assigned values outside YES or NO compile without complaint.
boolean minusOneTest = -1
print "minusOneTest == "; minusOneTest
// Typical boolean value is use
BOOL flatterRosettaReader = YES
if (flatterRosettaReader)
print
print @"Rosetta Code programmers understand booleans."
print
end if
// Defined Core Foundation boolean values
print "kCFBooleanTrue == "; kCFBooleanTrue
print "kCFBooleanFalse == "; kCFBooleanFalse
print
// Number object assigned literal value
CFNumberRef booleanObject = @(YES)
print "booleanObject == "; booleanObject
print
// Number object created programmatically
booleanObject = NO
print "booleanObject variable reassigned as N0 == "; fn NumberWithBool( booleanObject )
print
end fn
window 1
fn BooleanExercise
HandleEvents

View file

@ -0,0 +1,13 @@
1 < 2;
# true
2 < 1;
# false
# GAP has also the value fail, which cannot be used as a boolean but may be used i$
1 = fail;
# false
fail = fail;
# true

View file

@ -0,0 +1,8 @@
Public Sub Main()
Dim bX As Boolean
Print bX
bX = True
Print bX
End

View file

@ -0,0 +1,26 @@
package main
import (
"fmt"
"reflect"
"strconv"
)
func main() {
var n bool = true
fmt.Println(n) // prt true
fmt.Printf("%T\n", n) // prt bool
n = !n
fmt.Println(n) // prt false
x := 5
y := 8
fmt.Println("x == y:", x == y) // prt x == y: false
fmt.Println("x < y:", x < y) // prt x < y: true
fmt.Println("\nConvert String into Boolean Data type\n")
str1 := "japan"
fmt.Println("Before :", reflect.TypeOf(str1)) // prt Before : string
bolStr, _ := strconv.ParseBool(str1)
fmt.Println("After :", reflect.TypeOf(bolStr)) // prt After : bool
}

View file

@ -0,0 +1 @@
data Bool = False | True deriving (Eq, Ord, Enum, Read, Show, Bounded)

View file

@ -0,0 +1,21 @@
main
//Bits aka Booleans.
b $= bit()
b $= true
print(b)
b $= false
print(b)
//Non-zero values are true.
b $= bit(1)
print(b)
b $= -1
print(b)
//Zero values are false
b $= 0
print(b)
}

View file

@ -0,0 +1,9 @@
Idris> :doc Bool
Data type Prelude.Bool.Bool : Type
Boolean Data Type
Constructors:
False : Bool
True : Bool

View file

@ -0,0 +1 @@
let B be whether or not 123 is greater than 100;

View file

@ -0,0 +1 @@
if B is true, say "123 is greater than 100."

View file

@ -0,0 +1,9 @@
To decide whether the CPU is working correctly:
if 123 is greater than 100, decide yes;
otherwise decide no.
When play begins:
[convert to truth state...]
let B be whether or not the CPU is working correctly;
[...or use as a condition]
if the CPU is working correctly, say "Whew."

View file

@ -0,0 +1,2 @@
boolean valueA = true;
boolean valueB = false;

View file

@ -0,0 +1,2 @@
Boolean valueA = Boolean.TRUE;
Boolean valueB = Boolean.FALSE;

View file

@ -0,0 +1,2 @@
Boolean valueA = Boolean.valueOf(true);
Boolean valueB = Boolean.valueOf(false);

View file

@ -0,0 +1,4 @@
julia> if 1
println("true")
end
ERROR: type: non-boolean (Int64) used in boolean context

View file

@ -0,0 +1,7 @@
julia> bool(-2:2)
5-element Bool Array:
true
true
false
true
true

View file

@ -0,0 +1,8 @@
> 'true
true
> 'false
false
> (or 'false 'false)
false
> (or 'false 'true)
true

View file

@ -0,0 +1,4 @@
{if true then YES else NO}
-> YES
{if false then YES else NO}
-> NO

View file

@ -0,0 +1,11 @@
{def TRUE {lambda {:a :b} :a}}
-> TRUE
{def FALSE {lambda {:a :b} :b}}
-> FALSE
{def IF {lambda {:c :a :b} {:c :a :b}}}
-> IF
{IF TRUE yes no}
-> yes
{IF FALSE yes no}
-> no

View file

@ -0,0 +1,11 @@
!true
// => false
not false
// => true
var(x = true)
$x // => true
$x = false
$x // => false

View file

@ -0,0 +1,7 @@
local(x = string)
// size is 0
#x->size ? 'yes' | 'no'
local(x = '123fsfsd')
// size is 8
#x->size ? 'yes' | 'no'

View file

@ -0,0 +1,6 @@
put TRUE
-- 1
put FALSE
-- 0
if 23 then put "Hello"
-- "Hello"

View file

@ -0,0 +1,12 @@
int a = 0;
int b = 1;
int c;
string str1 = "initialized string";
string str2; // "uninitialized string";
if (a) {puts("first test a is false");} // This should not print
if (b) {puts("second test b is true");} // This should print
if (c) {puts("third test b is false");} // This should not print
if (!defined(c)) {puts("fourth test is true");} // This should print
if (str1) {puts("fifth test str1 is true");} // This should print
if (str2) {puts("sixth test str2 is false");} // This should not print

View file

@ -0,0 +1,4 @@
print 1 < 0 ; false
print 1 > 0 ; true
if "true [print "yes] ; yes
if not "false [print "no] ; no

View file

@ -0,0 +1,3 @@
if equal? 0 ln 1 [print "zero]
if empty? [] [print "empty] ; empty list
if empty? "|| [print "empty] ; empty word

View file

@ -0,0 +1,6 @@
if 0 then print "0" end -- This prints
if "" then print"empty string" end -- This prints
if {} then print"empty table" end -- This prints
if nil then print"this won't print" end
if true then print"true" end
if false then print"false" end -- This does not print

View file

@ -0,0 +1,29 @@
Module CheckBoolean {
A=True
Print Type$(A)="Double"
B=1=1
Print Type$(B)="Boolean"
Print A=B ' true
Print A, B ' -1 True
Def boolean C=True, D=False
Print C, D , 1>-3 ' True False True
K$=Str$(C)
Print K$="True" ' True
Function ShowBoolean$(&x) {
x=false
Try {
if keypress(32) then x=true : exit
If Keypress(13) then exit
loop
}
=str$(x, locale)
}
Wait 100
Print "C (space for true, enter for false)="; : Print ShowBoolean$(&c)
Print C
}
CheckBoolean
Print str$(True, "\t\r\u\e;\t\r\u\e;\f\a\l\s\e")="true"
Print str$(False, "\t\r\u\e;\t\r\u\e;\f\a\l\s\e")="false"
Print str$(2, "\t\r\u\e;\t\r\u\e;\f\a\l\s\e")="true"

View file

@ -0,0 +1,35 @@
>> islogical(true)
ans =
1
>> islogical(false)
ans =
1
>> islogical(logical(1))
ans =
1
>> islogical(logical(0))
ans =
1
>> islogical(1)
ans =
0
>> islogical(0)
ans =
0

View file

@ -0,0 +1,11 @@
is(1 < 2);
/* true */
is(2 < 1);
/* false */
not true;
/* false */
not false;
/* true */

View file

@ -0,0 +1,5 @@
If c Then
notc = "False"
Else
notc = "True"
EndIf

View file

@ -0,0 +1,11 @@
boolTrue = true
boolFalse = false
if boolTrue then print "boolTrue is true, and its value is: " + boolTrue
if not boolFalse then print "boolFalse is not true, and its value is: " + boolFalse
mostlyTrue = 0.8
kindaTrue = 0.4
print "mostlyTrue AND kindaTrue: " + (mostlyTrue and kindaTrue)
print "mostlyTrue OR kindaTrue: " + (mostlyTrue or kindaTrue)

View file

@ -0,0 +1,28 @@
import java.util.ArrayList
import java.util.HashMap
# booleans
puts 'true is true' if true
puts 'false is false' if (!false)
# lists treated as booleans
x = ArrayList.new
puts "empty array is true" if x
x.add("an element")
puts "full array is true" if x
puts "isEmpty() is false" if !x.isEmpty()
# maps treated as booleans
map = HashMap.new
puts "empty map is true" if map
map.put('a', '1')
puts "full map is true" if map
puts "size() is 0 is false" if !(map.size() == 0)
# these things do not compile
# value = nil # ==> cannot assign nil to Boolean value
# puts 'nil is false' if false == nil # ==> cannot compare boolean to nil
# puts '0 is false' if (0 == false) # ==> cannot compare int to false
#puts 'TRUE is true' if TRUE # ==> TRUE does not exist
#puts 'FALSE is false' if !FALSE # ==> FALSE does not exist

View file

@ -0,0 +1,17 @@
MODULE boo;
IMPORT InOut;
VAR result, done : BOOLEAN;
A, B : INTEGER;
BEGIN
result := (1 = 2);
result := NOT result;
done := FALSE;
REPEAT
InOut.ReadInt (A);
InOut.ReadInt (B);
done := A > B
UNTIL done
END boo.

View file

@ -0,0 +1 @@
TYPE BOOLEAN = {FALSE, TRUE}

View file

@ -0,0 +1,4 @@
def example(input :boolean):
if input:
return "Input was true!"
return "Input was false."

View file

@ -0,0 +1,8 @@
a = true
b = false
if a
println "a is true"
else if b
println "b is true"
end

View file

@ -0,0 +1,27 @@
/* boolean values */
$print(true, "\n");
$print(false, "\n");
if 0 {
$print("literal 0 tests true\n");
} else {
$print("literal 0 tests false\n");
}
if 1 {
$print("literal 1 tests true\n");
} else {
$print("literal 1 tests false\n");
}
if $istrue(0) {
$print("$istrue(0) tests true\n");
} else {
$print("$istrue(0) tests false\n");
}
if $istrue(1) {
$print("$istrue(1) tests true\n");
} else {
$print("$istrue(1) tests false\n");
}

View file

@ -0,0 +1,18 @@
/* NetRexx */
options replace format comments java crossref savelog symbols nobinary
bval = [1, 0, 5, 'a', 1 == 1, 1 \= 1, isTrue, isFalse]
loop b_ = 0 for bval.length
select case bval[b_]
when isTrue then say bval[b_] 'is true'
when isFalse then say bval[b_] 'is false'
otherwise say bval[b_] 'is not boolean'
end
end b_
method isTrue public static returns boolean
return (1 == 1)
method isFalse public static returns boolean
return \isTrue

View file

@ -0,0 +1,5 @@
if true: echo "yes"
if false: echo "no"
# Other objects never represent true or false:
if 2: echo "compile error"

View file

@ -0,0 +1 @@
type bool = false | true

View file

@ -0,0 +1,6 @@
VAR
a,b,c: BOOLEAN;
...
a := TRUE;
b := FALSE;
c := 1 > 2;

View file

@ -0,0 +1,3 @@
Declare x bit(1);
x='1'b; /* True */
x='0'b; /* False */

View file

@ -0,0 +1,11 @@
*process source attributes xref macro or(!);
tf: proc options(main);
%Dcl true char; %true='''1''b';
%Dcl false char; %false='''0''b';
If true Then
Put Skip list('That''s true');
If false Then
Put Skip List('ERROR');
Else
Put Skip List('false was recognized');
End;

View file

@ -0,0 +1,4 @@
IF 0 THEN /* THIS WON'T RUN */;
IF 1 THEN /* THIS WILL */;
IF 2 THEN /* THIS WON'T */;
IF 3 THEN /* THIS WILL */;

View file

@ -0,0 +1,3 @@
DECLARE A BYTE;
A = 4 < 5;
/* A IS NOW 0FFH */

View file

@ -0,0 +1 @@
DECLARE FALSE LITERALLY '0', TRUE LITERALLY '0FFH';

Some files were not shown because too many files have changed in this diff Show more