Skip to main content

module Boolean

Usage

import Boolean;

Synopsis

Library functions for Booleans.

Description

For operators on Boolean values see Boolean in the Rascal Language Reference.

The following functions are defined for Booleans:

function arbBool

bool arbBool()

Synopsis

Return an arbitrary Boolean value.

Examples

rascal>import Boolean;
ok
rascal>arbBool();
bool: true
rascal>arbBool();
bool: true
rascal>arbBool();
bool: true

Benefits

arbInt is a convenient generator for arbitrary binary choices.

function fromString

bool fromString(str s)

Synopsis

Convert the strings "true" or "false" to a bool.

function toInt

int toInt(bool b)

Synopsis

Convert a Boolean value to integer.

Description

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

real toReal(bool b)

Synopsis

Convert Boolean value to real.

Description

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

str toString(bool b)

Synopsis

Convert Boolean value to string.

Description

Maps true to "true" and false to "false".

Examples

rascal>import Boolean;
ok
rascal>toString(true);
str: "true"
rascal>toString(false);
str: "false"