8.5  Match

8.5 Match

The following matches Expr1, a pattern, against Expr2:

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> {A, B} = {answer, 42}.
{answer,42}
2> A.
answer
3> {C, D} = [1, 2].
** exception error: no match of right-hand side value [1,2]