Boolean All
rascal-0.34.0
Synopsis
All argument expressions are true.
Syntax
all ( Exp₁, Exp₂, ... )
Types
//
Exp₁ | Exp₂ | ... | all ( Exp₁, Exp₂, ... ) |
---|---|---|---|
bool | bool | ... | bool |
Description
Yields true
when all combinations of values of Expᵢ are true.
Examples
Are all integers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 even?
rascal>all(int n <- [1 .. 10], n % 2 == 0);
bool: false
Are all integers 0, 2, 4, 6, 8, 10 even?
rascal>all(int n <- [0, 2 .. 10], n % 2 == 0);
bool: true
When one of the Expᵢ enumerates the elements of an empty list, all
always returns true
:
rascal>all(int n <- [], n > 0);
bool: false
Pitfalls
WARNING: The Rascal interpreter and compiler give different results on an empty list.
The interpreter returns fals
for the abo eexample.