Navigation
Synopsis Match a pattern against an expression.
Syntax Pat := Exp
Types
Pat Exp Pat := Exp
Patterns value bool
Description See PatternMatching for an introduction to pattern matching and Patterns for a complete description.
Examples
rascal>123 := 456;
bool: false
rascal>[10, N*, 50] := [10, 20, 30, 40, 50];
bool: true
rascal>{10, set[int] S, 50} := {50, 40, 30, 30, 10};
bool: false

Questions
Question [1]. Determine the number of strings that contain "a".
Fill in
text = ["andra", "moi", "ennepe", "Mousa", "polutropon"];
public int count(list[str] text){
  n = 0;
  for(s <- text)
    if( := s)
      n +=1;
  return n;
}
and make the following true:
count(text) == 2;



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.