Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
5
Task/Boolean-values/00-META.yaml
Normal file
5
Task/Boolean-values/00-META.yaml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
category:
|
||||
- Simple
|
||||
from: http://rosettacode.org/wiki/Boolean_values
|
||||
note: Basic language learning
|
||||
9
Task/Boolean-values/00-TASK.txt
Normal file
9
Task/Boolean-values/00-TASK.txt
Normal 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>
|
||||
2
Task/Boolean-values/360-Assembly/boolean-values.360
Normal file
2
Task/Boolean-values/360-Assembly/boolean-values.360
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
FALSE DC X'00'
|
||||
TRUE DC X'FF'
|
||||
2
Task/Boolean-values/8051-Assembly/boolean-values.8051
Normal file
2
Task/Boolean-values/8051-Assembly/boolean-values.8051
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
clr bit ; clears
|
||||
setb bit ; sets
|
||||
50
Task/Boolean-values/AArch64-Assembly/boolean-values.aarch64
Normal file
50
Task/Boolean-values/AArch64-Assembly/boolean-values.aarch64
Normal 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"
|
||||
30
Task/Boolean-values/ALGOL-68/boolean-values.alg
Normal file
30
Task/Boolean-values/ALGOL-68/boolean-values.alg
Normal 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
|
||||
4
Task/Boolean-values/APL/boolean-values.apl
Normal file
4
Task/Boolean-values/APL/boolean-values.apl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
1 ^ 1
|
||||
1
|
||||
1 ^ 0
|
||||
0
|
||||
64
Task/Boolean-values/ARM-Assembly/boolean-values.arm
Normal file
64
Task/Boolean-values/ARM-Assembly/boolean-values.arm
Normal 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 */
|
||||
18
Task/Boolean-values/AWK/boolean-values.awk
Normal file
18
Task/Boolean-values/AWK/boolean-values.awk
Normal 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
|
||||
|
||||
}
|
||||
30
Task/Boolean-values/Action-/boolean-values.action
Normal file
30
Task/Boolean-values/Action-/boolean-values.action
Normal 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
|
||||
1
Task/Boolean-values/Ada/boolean-values.ada
Normal file
1
Task/Boolean-values/Ada/boolean-values.ada
Normal file
|
|
@ -0,0 +1 @@
|
|||
type Boolean is (False, True);
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
{yes as boolean, no as boolean}
|
||||
--> {true, false}
|
||||
|
|
@ -0,0 +1 @@
|
|||
sortItems from L given reversal : true
|
||||
|
|
@ -0,0 +1 @@
|
|||
sortItems from L with reversal
|
||||
|
|
@ -0,0 +1 @@
|
|||
sortItems from L given reversal:yes
|
||||
3
Task/Boolean-values/Applesoft-BASIC/boolean-values.basic
Normal file
3
Task/Boolean-values/Applesoft-BASIC/boolean-values.basic
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
? 2 = 3
|
||||
? 2 = 2
|
||||
IF 7 THEN ?"HELLO"
|
||||
7
Task/Boolean-values/Arturo/boolean-values.arturo
Normal file
7
Task/Boolean-values/Arturo/boolean-values.arturo
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
a: true
|
||||
b: false
|
||||
|
||||
if? a [ print "yep" ] else [ print "nope" ]
|
||||
|
||||
if? b -> print "nope"
|
||||
else -> print "yep"
|
||||
11
Task/Boolean-values/BASIC/boolean-values.basic
Normal file
11
Task/Boolean-values/BASIC/boolean-values.basic
Normal 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
|
||||
7
Task/Boolean-values/BASIC256/boolean-values.basic
Normal file
7
Task/Boolean-values/BASIC256/boolean-values.basic
Normal 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
|
||||
5
Task/Boolean-values/BBC-BASIC/boolean-values.basic
Normal file
5
Task/Boolean-values/BBC-BASIC/boolean-values.basic
Normal 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
|
||||
8
Task/Boolean-values/BaCon/boolean-values.bacon
Normal file
8
Task/Boolean-values/BaCon/boolean-values.bacon
Normal 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"
|
||||
19
Task/Boolean-values/Batch-File/boolean-values.bat
Normal file
19
Task/Boolean-values/Batch-File/boolean-values.bat
Normal 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
|
||||
1
Task/Boolean-values/C-sharp/boolean-values.cs
Normal file
1
Task/Boolean-values/C-sharp/boolean-values.cs
Normal file
|
|
@ -0,0 +1 @@
|
|||
bool? value = null
|
||||
8
Task/Boolean-values/CMake/boolean-values.cmake
Normal file
8
Task/Boolean-values/CMake/boolean-values.cmake
Normal 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)
|
||||
1
Task/Boolean-values/COBOL/boolean-values-1.cobol
Normal file
1
Task/Boolean-values/COBOL/boolean-values-1.cobol
Normal file
|
|
@ -0,0 +1 @@
|
|||
01 some-bool PIC 1 BIT.
|
||||
4
Task/Boolean-values/COBOL/boolean-values-2.cobol
Normal file
4
Task/Boolean-values/COBOL/boolean-values-2.cobol
Normal 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.
|
||||
28
Task/Boolean-values/COBOL/boolean-values-3.cobol
Normal file
28
Task/Boolean-values/COBOL/boolean-values-3.cobol
Normal 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
|
||||
.
|
||||
1
Task/Boolean-values/Clean/boolean-values.clean
Normal file
1
Task/Boolean-values/Clean/boolean-values.clean
Normal file
|
|
@ -0,0 +1 @@
|
|||
::Bool = False | True
|
||||
28
Task/Boolean-values/CoffeeScript/boolean-values.coffee
Normal file
28
Task/Boolean-values/CoffeeScript/boolean-values.coffee
Normal 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
|
||||
]
|
||||
11
Task/Boolean-values/Commodore-BASIC/boolean-values.basic
Normal file
11
Task/Boolean-values/Commodore-BASIC/boolean-values.basic
Normal 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
|
||||
6
Task/Boolean-values/Component-Pascal/boolean-values.pas
Normal file
6
Task/Boolean-values/Component-Pascal/boolean-values.pas
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
VAR
|
||||
b,c: BOOLEAN;
|
||||
...
|
||||
b := TRUE;
|
||||
c := FALSE;
|
||||
...
|
||||
9
Task/Boolean-values/Crystal/boolean-values.crystal
Normal file
9
Task/Boolean-values/Crystal/boolean-values.crystal
Normal 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
|
||||
2
Task/Boolean-values/Dylan/boolean-values.dylan
Normal file
2
Task/Boolean-values/Dylan/boolean-values.dylan
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#t // <boolean> true
|
||||
#f // <boolean> false
|
||||
8
Task/Boolean-values/E/boolean-values-1.e
Normal file
8
Task/Boolean-values/E/boolean-values-1.e
Normal 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
|
||||
7
Task/Boolean-values/E/boolean-values-2.e
Normal file
7
Task/Boolean-values/E/boolean-values-2.e
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
? def bowlian {
|
||||
> to __conformTo(guard) {
|
||||
> if (guard == boolean) { return true }
|
||||
> }
|
||||
> }
|
||||
> if (bowlian) { "a" } else { "b" }
|
||||
# value: "a"
|
||||
20
Task/Boolean-values/EGL/boolean-values.egl
Normal file
20
Task/Boolean-values/EGL/boolean-values.egl
Normal 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));
|
||||
18
Task/Boolean-values/EMal/boolean-values.emal
Normal file
18
Task/Boolean-values/EMal/boolean-values.emal
Normal 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 "⊥"
|
||||
12
Task/Boolean-values/EasyLang/boolean-values.easy
Normal file
12
Task/Boolean-values/EasyLang/boolean-values.easy
Normal 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"
|
||||
.
|
||||
4
Task/Boolean-values/EchoLisp/boolean-values.l
Normal file
4
Task/Boolean-values/EchoLisp/boolean-values.l
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(not #t) → #f
|
||||
(not #f) → #t
|
||||
(not null) → #f
|
||||
(not 0) → #f
|
||||
18
Task/Boolean-values/Ecstasy/boolean-values.ecstasy
Normal file
18
Task/Boolean-values/Ecstasy/boolean-values.ecstasy
Normal 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}");
|
||||
}
|
||||
}
|
||||
6
Task/Boolean-values/Elixir/boolean-values-1.elixir
Normal file
6
Task/Boolean-values/Elixir/boolean-values-1.elixir
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
iex(1)> true === :true
|
||||
true
|
||||
iex(2)> false === :false
|
||||
true
|
||||
iex(3)> true === 1
|
||||
false
|
||||
4
Task/Boolean-values/Elixir/boolean-values-2.elixir
Normal file
4
Task/Boolean-values/Elixir/boolean-values-2.elixir
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
iex(4)> nil === :nil
|
||||
true
|
||||
iex(5)> nil === false
|
||||
false
|
||||
44
Task/Boolean-values/Elm/boolean-values.elm
Normal file
44
Task/Boolean-values/Elm/boolean-values.elm
Normal 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
|
||||
6
Task/Boolean-values/Erlang/boolean-values.erl
Normal file
6
Task/Boolean-values/Erlang/boolean-values.erl
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
1> 1 < 2.
|
||||
true
|
||||
2> 1 < 1.
|
||||
false
|
||||
3> 0 == false.
|
||||
false
|
||||
1
Task/Boolean-values/Excel/boolean-values-1.excel
Normal file
1
Task/Boolean-values/Excel/boolean-values-1.excel
Normal file
|
|
@ -0,0 +1 @@
|
|||
=AND(A1;B1)
|
||||
4
Task/Boolean-values/Excel/boolean-values-2.excel
Normal file
4
Task/Boolean-values/Excel/boolean-values-2.excel
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
0 0 FALSE
|
||||
0 1 FALSE
|
||||
1 0 FALSE
|
||||
1 1 TRUE
|
||||
1
Task/Boolean-values/F-Sharp/boolean-values.fs
Normal file
1
Task/Boolean-values/F-Sharp/boolean-values.fs
Normal file
|
|
@ -0,0 +1 @@
|
|||
type bool = System.Boolean
|
||||
2
Task/Boolean-values/Forth/boolean-values.fth
Normal file
2
Task/Boolean-values/Forth/boolean-values.fth
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
TRUE . \ -1
|
||||
FALSE . \ 0
|
||||
5
Task/Boolean-values/Fortran/boolean-values-1.f
Normal file
5
Task/Boolean-values/Fortran/boolean-values-1.f
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
TYPE MIXED
|
||||
LOGICAL*1 LIVE
|
||||
REAL*8 VALUE
|
||||
END TYPE MIXED
|
||||
TYPE(MIXED) STUFF(100)
|
||||
5
Task/Boolean-values/Fortran/boolean-values-2.f
Normal file
5
Task/Boolean-values/Fortran/boolean-values-2.f
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
TYPE MIXED
|
||||
LOGICAL*1 LIVE(100)
|
||||
REAL*8 VALUE(100)
|
||||
END TYPE MIXED
|
||||
TYPE(MIXED) STUFF
|
||||
23
Task/Boolean-values/Free-Pascal-Lazarus/boolean-values.pas
Normal file
23
Task/Boolean-values/Free-Pascal-Lazarus/boolean-values.pas
Normal 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;
|
||||
14
Task/Boolean-values/FreeBASIC/boolean-values.basic
Normal file
14
Task/Boolean-values/FreeBASIC/boolean-values.basic
Normal 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
|
||||
5
Task/Boolean-values/FutureBasic/boolean-values-1.basic
Normal file
5
Task/Boolean-values/FutureBasic/boolean-values-1.basic
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
window 1
|
||||
BOOL boolTest
|
||||
boolTest = -1
|
||||
print boolTest
|
||||
HandleEvents
|
||||
1
Task/Boolean-values/FutureBasic/boolean-values-2.basic
Normal file
1
Task/Boolean-values/FutureBasic/boolean-values-2.basic
Normal 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]
|
||||
42
Task/Boolean-values/FutureBasic/boolean-values-3.basic
Normal file
42
Task/Boolean-values/FutureBasic/boolean-values-3.basic
Normal 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
|
||||
13
Task/Boolean-values/GAP/boolean-values.gap
Normal file
13
Task/Boolean-values/GAP/boolean-values.gap
Normal 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
|
||||
8
Task/Boolean-values/Gambas/boolean-values.gambas
Normal file
8
Task/Boolean-values/Gambas/boolean-values.gambas
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
Public Sub Main()
|
||||
Dim bX As Boolean
|
||||
|
||||
Print bX
|
||||
bX = True
|
||||
Print bX
|
||||
|
||||
End
|
||||
26
Task/Boolean-values/Go/boolean-values.go
Normal file
26
Task/Boolean-values/Go/boolean-values.go
Normal 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
|
||||
}
|
||||
1
Task/Boolean-values/Haskell/boolean-values.hs
Normal file
1
Task/Boolean-values/Haskell/boolean-values.hs
Normal file
|
|
@ -0,0 +1 @@
|
|||
data Bool = False | True deriving (Eq, Ord, Enum, Read, Show, Bounded)
|
||||
21
Task/Boolean-values/I/boolean-values.i
Normal file
21
Task/Boolean-values/I/boolean-values.i
Normal 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)
|
||||
}
|
||||
9
Task/Boolean-values/Idris/boolean-values.idris
Normal file
9
Task/Boolean-values/Idris/boolean-values.idris
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
Idris> :doc Bool
|
||||
Data type Prelude.Bool.Bool : Type
|
||||
Boolean Data Type
|
||||
|
||||
Constructors:
|
||||
False : Bool
|
||||
|
||||
|
||||
True : Bool
|
||||
1
Task/Boolean-values/Inform-7/boolean-values-1.inf
Normal file
1
Task/Boolean-values/Inform-7/boolean-values-1.inf
Normal file
|
|
@ -0,0 +1 @@
|
|||
let B be whether or not 123 is greater than 100;
|
||||
1
Task/Boolean-values/Inform-7/boolean-values-2.inf
Normal file
1
Task/Boolean-values/Inform-7/boolean-values-2.inf
Normal file
|
|
@ -0,0 +1 @@
|
|||
if B is true, say "123 is greater than 100."
|
||||
9
Task/Boolean-values/Inform-7/boolean-values-3.inf
Normal file
9
Task/Boolean-values/Inform-7/boolean-values-3.inf
Normal 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."
|
||||
2
Task/Boolean-values/Java/boolean-values-1.java
Normal file
2
Task/Boolean-values/Java/boolean-values-1.java
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
boolean valueA = true;
|
||||
boolean valueB = false;
|
||||
2
Task/Boolean-values/Java/boolean-values-2.java
Normal file
2
Task/Boolean-values/Java/boolean-values-2.java
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Boolean valueA = Boolean.TRUE;
|
||||
Boolean valueB = Boolean.FALSE;
|
||||
2
Task/Boolean-values/Java/boolean-values-3.java
Normal file
2
Task/Boolean-values/Java/boolean-values-3.java
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Boolean valueA = Boolean.valueOf(true);
|
||||
Boolean valueB = Boolean.valueOf(false);
|
||||
4
Task/Boolean-values/Julia/boolean-values-1.julia
Normal file
4
Task/Boolean-values/Julia/boolean-values-1.julia
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
julia> if 1
|
||||
println("true")
|
||||
end
|
||||
ERROR: type: non-boolean (Int64) used in boolean context
|
||||
7
Task/Boolean-values/Julia/boolean-values-2.julia
Normal file
7
Task/Boolean-values/Julia/boolean-values-2.julia
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
julia> bool(-2:2)
|
||||
5-element Bool Array:
|
||||
true
|
||||
true
|
||||
false
|
||||
true
|
||||
true
|
||||
8
Task/Boolean-values/LFE/boolean-values.lfe
Normal file
8
Task/Boolean-values/LFE/boolean-values.lfe
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
> 'true
|
||||
true
|
||||
> 'false
|
||||
false
|
||||
> (or 'false 'false)
|
||||
false
|
||||
> (or 'false 'true)
|
||||
true
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{if true then YES else NO}
|
||||
-> YES
|
||||
{if false then YES else NO}
|
||||
-> NO
|
||||
11
Task/Boolean-values/Lambdatalk/boolean-values-2.lambdatalk
Normal file
11
Task/Boolean-values/Lambdatalk/boolean-values-2.lambdatalk
Normal 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
|
||||
11
Task/Boolean-values/Lasso/boolean-values-1.lasso
Normal file
11
Task/Boolean-values/Lasso/boolean-values-1.lasso
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
!true
|
||||
// => false
|
||||
|
||||
not false
|
||||
// => true
|
||||
|
||||
var(x = true)
|
||||
$x // => true
|
||||
|
||||
$x = false
|
||||
$x // => false
|
||||
7
Task/Boolean-values/Lasso/boolean-values-2.lasso
Normal file
7
Task/Boolean-values/Lasso/boolean-values-2.lasso
Normal 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'
|
||||
6
Task/Boolean-values/Lingo/boolean-values.lingo
Normal file
6
Task/Boolean-values/Lingo/boolean-values.lingo
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
put TRUE
|
||||
-- 1
|
||||
put FALSE
|
||||
-- 0
|
||||
if 23 then put "Hello"
|
||||
-- "Hello"
|
||||
12
Task/Boolean-values/Little/boolean-values.little
Normal file
12
Task/Boolean-values/Little/boolean-values.little
Normal 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
|
||||
4
Task/Boolean-values/Logo/boolean-values-1.logo
Normal file
4
Task/Boolean-values/Logo/boolean-values-1.logo
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
print 1 < 0 ; false
|
||||
print 1 > 0 ; true
|
||||
if "true [print "yes] ; yes
|
||||
if not "false [print "no] ; no
|
||||
3
Task/Boolean-values/Logo/boolean-values-2.logo
Normal file
3
Task/Boolean-values/Logo/boolean-values-2.logo
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
if equal? 0 ln 1 [print "zero]
|
||||
if empty? [] [print "empty] ; empty list
|
||||
if empty? "|| [print "empty] ; empty word
|
||||
6
Task/Boolean-values/Lua/boolean-values.lua
Normal file
6
Task/Boolean-values/Lua/boolean-values.lua
Normal 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
|
||||
29
Task/Boolean-values/M2000-Interpreter/boolean-values.m2000
Normal file
29
Task/Boolean-values/M2000-Interpreter/boolean-values.m2000
Normal 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"
|
||||
35
Task/Boolean-values/MATLAB/boolean-values.m
Normal file
35
Task/Boolean-values/MATLAB/boolean-values.m
Normal 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
|
||||
11
Task/Boolean-values/Maxima/boolean-values.maxima
Normal file
11
Task/Boolean-values/Maxima/boolean-values.maxima
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
is(1 < 2);
|
||||
/* true */
|
||||
|
||||
is(2 < 1);
|
||||
/* false */
|
||||
|
||||
not true;
|
||||
/* false */
|
||||
|
||||
not false;
|
||||
/* true */
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
If c Then
|
||||
notc = "False"
|
||||
Else
|
||||
notc = "True"
|
||||
EndIf
|
||||
11
Task/Boolean-values/MiniScript/boolean-values.mini
Normal file
11
Task/Boolean-values/MiniScript/boolean-values.mini
Normal 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)
|
||||
28
Task/Boolean-values/Mirah/boolean-values.mirah
Normal file
28
Task/Boolean-values/Mirah/boolean-values.mirah
Normal 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
|
||||
17
Task/Boolean-values/Modula-2/boolean-values.mod2
Normal file
17
Task/Boolean-values/Modula-2/boolean-values.mod2
Normal 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.
|
||||
1
Task/Boolean-values/Modula-3/boolean-values.mod3
Normal file
1
Task/Boolean-values/Modula-3/boolean-values.mod3
Normal file
|
|
@ -0,0 +1 @@
|
|||
TYPE BOOLEAN = {FALSE, TRUE}
|
||||
4
Task/Boolean-values/Monte/boolean-values.monte
Normal file
4
Task/Boolean-values/Monte/boolean-values.monte
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
def example(input :boolean):
|
||||
if input:
|
||||
return "Input was true!"
|
||||
return "Input was false."
|
||||
8
Task/Boolean-values/Nanoquery/boolean-values.nanoquery
Normal file
8
Task/Boolean-values/Nanoquery/boolean-values.nanoquery
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
a = true
|
||||
b = false
|
||||
|
||||
if a
|
||||
println "a is true"
|
||||
else if b
|
||||
println "b is true"
|
||||
end
|
||||
27
Task/Boolean-values/Neko/boolean-values.neko
Normal file
27
Task/Boolean-values/Neko/boolean-values.neko
Normal 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");
|
||||
}
|
||||
18
Task/Boolean-values/NetRexx/boolean-values.netrexx
Normal file
18
Task/Boolean-values/NetRexx/boolean-values.netrexx
Normal 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
|
||||
5
Task/Boolean-values/Nim/boolean-values.nim
Normal file
5
Task/Boolean-values/Nim/boolean-values.nim
Normal 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"
|
||||
1
Task/Boolean-values/OCaml/boolean-values.ocaml
Normal file
1
Task/Boolean-values/OCaml/boolean-values.ocaml
Normal file
|
|
@ -0,0 +1 @@
|
|||
type bool = false | true
|
||||
6
Task/Boolean-values/Oberon/boolean-values.oberon
Normal file
6
Task/Boolean-values/Oberon/boolean-values.oberon
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
VAR
|
||||
a,b,c: BOOLEAN;
|
||||
...
|
||||
a := TRUE;
|
||||
b := FALSE;
|
||||
c := 1 > 2;
|
||||
3
Task/Boolean-values/PL-I/boolean-values-1.pli
Normal file
3
Task/Boolean-values/PL-I/boolean-values-1.pli
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Declare x bit(1);
|
||||
x='1'b; /* True */
|
||||
x='0'b; /* False */
|
||||
11
Task/Boolean-values/PL-I/boolean-values-2.pli
Normal file
11
Task/Boolean-values/PL-I/boolean-values-2.pli
Normal 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;
|
||||
4
Task/Boolean-values/PL-M/boolean-values-1.plm
Normal file
4
Task/Boolean-values/PL-M/boolean-values-1.plm
Normal 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 */;
|
||||
3
Task/Boolean-values/PL-M/boolean-values-2.plm
Normal file
3
Task/Boolean-values/PL-M/boolean-values-2.plm
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
DECLARE A BYTE;
|
||||
A = 4 < 5;
|
||||
/* A IS NOW 0FFH */
|
||||
1
Task/Boolean-values/PL-M/boolean-values-3.plm
Normal file
1
Task/Boolean-values/PL-M/boolean-values-3.plm
Normal 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
Loading…
Add table
Add a link
Reference in a new issue