Rules and Patterns

WMA link

The concept of transformation rules for arbitrary symbolic patterns is key in Mathics3.

Also, functions can get applied or transformed depending on whether or not functions arguments match.

Some examples:

Tests and Conditions:

Elements in the beginning of a pattern rather match fewer elements:

Optional arguments using Optional:

Options using OptionsPattern and OptionValue:

The attributes Flat, Orderless, and OneIdentity affect pattern matching.

Procedural Programming
Scoping Constructs