module Boolean
rascal-Not specified
Library functions for Booleans.
Usage
import Boolean;
Dependencies
import Exception;
Description
The following library functions are defined for Booleans:
function arbBool
Return an arbitrary Boolean value.
bool arbBool()
Examples
rascal>import Boolean;
ok
rascal>arbBool();
bool: true
rascal>arbBool();
bool: true
rascal>arbBool();
bool: true
Benefits
arbBoolis a convenient generator for arbitrary binary choices.
function fromString
Convert the strings "true" or "false" to a bool.
bool fromString(str s)
function toInt
Convert a Boolean value to integer.
int toInt(bool b)
Maps true to 1 and false to 0.
Examples
rascal>import Boolean;
ok
rascal>toInt(true);
int: 1
rascal>toInt(false);
int: 0
function toReal
Convert Boolean value to real.
real toReal(bool b)
Maps true to 1.0 and false to 0.0.
Examples
rascal>import Boolean;
ok
rascal>toReal(true);
real: 1.0
rascal>toReal(false);
real: 0.0
function toString
Convert Boolean value to string.
str toString(bool b)
Maps true to "true" and false to "false".
Examples
rascal>import Boolean;
ok
rascal>toString(true);
str: "true"
───
true
───
rascal>toString(false);
str: "false"
───
false
───