WolframLang: Pattern Matching

By Xah Lee. Date: . Last updated: .

Pattern matching is a core mechanism how WolframLang does computation. WolframLang is a term-rewriting system, meaning, it transform expressions according to rules until no rule matches.

A rule is a pair of values that looks like this:

left-hand-sideright-hand-side

The left-hand-side is a pattern (which includes literal expression). The right-hand-side is replacement, which may include parts of the captured pattern.

For the transformation, there are local and global transformations:

Creating Rules

Pattern Syntax

Functions that Transform Expression by Rules

Pattern Matching