8.5 Match

The following matches Expr1, a pattern, against Expr2:

  1. Expr1 = Expr2

If the matching succeeds, any unbound variable in the pattern becomes bound and the value of Expr2 is returned.

If the matching fails, a badmatch run-time error occurs.

Examples:

  1. 1> {A, B} = {answer, 42}.
  2. {answer,42}
  3. 2> A.
  4. answer
  5. 3> {C, D} = [1, 2].
  6. ** exception error: no match of right-hand side value [1,2]