Boolean values: Difference between revisions

m
(→‎Insitux: inclusion)
imported>Tromp
 
(9 intermediate revisions by 4 users not shown)
Line 551:
if not(2 < 1) then print "2 not < 1"
if not(1 = 0) then print "1 not = 0"</syntaxhighlight>
 
==={{header|SmallBASIC}}===
<syntaxhighlight lang="basic">
a = true
b = false
</syntaxhighlight>
 
==={{header|smart BASIC}}===
Line 659 ⟶ 665:
=={{header|Befunge}}==
Zero is false, non-zero is true. This is only used by the horizontal and vertical switch operators (<code>_</code> and <code>|</code>).
 
=={{header|Binary Lambda Calculus}}==
 
The standard representations for the booleans in lambda calculus are true = \then. \else. then, false = \then. \else. else, which correspond to BLC programs <code>00 00 110</code> and <code>00 00 10</code>.
 
=={{header|BQN}}==
 
Line 2,420 ⟶ 2,431:
v := 1.bool; -- ok
if i.bool then ... end; -- ok</syntaxhighlight>
 
In this case, <code>0.bool</code> is false, and <code>n.bool</code> with n not equal to 0 is true.
 
=={{header|S-BASIC}}==
Although S-BASIC has no explicit boolean data type, it allows integer,
real, fixed, string, and character variables to hold the results of boolean operations and to represent true and false conditions in IF, WHILE, and REPEAT statements. For types real.double, real, and fixed, a value of zero is false, and any non-zero value is true. For integers, the value 0 is treated as false, while -1 (or FFFFH), the bit-wise negation of zero, is treated as true.
For characters and strings, 'Y', 'y', 'T', and 't' are treated as true,
while 'N', 'n', 'F', and 'f' are treated as false. (For strings, only the first character is considered.) For convenience, the $CONSTANT compiler directive can be used to provide values for "true" and "false".
<syntaxhighlight lang = "BASIC">
$constant true = 0FFFFH
$constant false = 0
 
var a, another = char
var b, adult, age = integer
var c = real
 
repeat
begin
input "Applicant's age in years"; age
adult = (age >= 18)
if adult then
print "Applicant has full access"
else
print "Applicant has restricted access"
input "Do another (y/n)"; another
end
until not another
 
a = (2 > 3)
b = (2 > 3)
c = (2 > 3)
print "2 > 3 as char: "; a
print "2 > 3 as int : "; b
print "not (2 > 3) : "; not b
print "2 > 3 as real: "; c
print "not (2 > 3) : "; not c
end
</syntaxhighlight>
{{out}}
<pre>
Applicant's age in years? 19
Applicant has full access
Do another (y/n)? n
2 > 3 as char: F
2 > 3 as int : 0
not (2 > 3) :-1
2 > 3 as real: 0
not (2 > 3) :-1
</pre>
 
=={{header|Scala}}==
Booleans in Scala are given by the literals <code>true</code> and <code>false</code>, case sensitive, which are the only instances of the class <code>Boolean</code>.
Line 2,449 ⟶ 2,508:
is False
</pre>
 
=={{header|Sidef}}==
Sidef defines the ''true'' and ''false'' boolean values, which are part of the ''Bool'' type.
Line 2,628 ⟶ 2,688:
 
This class has two methods: the operator ''!'' which returns the logical complement of its receiver and ''toString'' which returns its string representation.
<syntaxhighlight lang="ecmascriptwren">var embed = true
System.printAll([embed, ", ", !embed, ", ", "Is Wren embeddable? " + embed.toString])</syntaxhighlight>
 
Line 2,635 ⟶ 2,695:
true, false, Is Wren embeddable? true
</pre>
 
=={{header|XLISP}}==
Boolean "false" may be represented by <tt>#F</tt>, <tt>#!FALSE</tt>, <tt>NIL</tt>, or the empty list; any other value is counted as true in conditional expressions, but it is also possible to represent the Boolean value "true" using your choice of the symbols <tt>#T</tt>, <tt>#!TRUE</tt>, and <tt>T</tt>. All these symbols are case-insensitive. Note that <tt>T</tt>, unlike the others, is a variable: it is bound by default to the constant <tt>#T</tt>, but you can (although you shouldn't) assign it any other value including "false" (by doing something like <tt>(setq t nil)</tt>). Boolean values are printed as <tt>#T</tt> and <tt>()</tt>.
Anonymous user