Skip to main content

Boolean Match

rascal-0.34.0

Synopsis

Match a pattern against an expression.

Syntax

Pat := Exp

Types

//

PatExpPat := Exp
Patternsvaluebool

Description

See Patterns for a complete description of all possible patterns on the left-hand side of the match operator. This expression returns true while the pattern matches.

  • if the pattern is unitary, it can match only in one way, and it does then true is returned once.
  • if the pattern is non-unitary, it could match in multiple ways, then every time the expression is evaluated it will return true and bind its variables in a different way.

Examples

rascal>123 := 456;
bool: false
rascal>[10, *n, 50] := [10, 20, 30, 40, 50];
bool: true
rascal>{10, *int n, 50} := {50, 40, 30, 30, 10};
bool: true