Navigation
Synopsis Success-directed control structures.
Description Control structures like If, While and For statement are driven by Boolean expressions. Actually, combinations of generators and Boolean expressions can be used to drive the control structures. In the latter case, the Boolean expression is executed for each generated value.
Examples A classical if statement:
if(N <= 0)
     return 1; 
  else
     return N * fac(N - 1);
A combination of a generator and a test:
for(/asgStat(Id name, _) <- P, size(name) > 10){
    println(name);
}
This statement prints all identifiers in assignment statements (asgStat) that consist of more than 10 characters.
Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.