Mathematica 9 is now available

Wolfram Library Archive

All Collections Articles Books Conference Proceedings
Courseware Demos MathSource Technical Notes
Title Downloads

Named Patterns in (lhs->rhs), (lhs=rhs), (lhs^=rhs), (f/:lhs=rhs)

Ted Ersek
Organization: Naval Air Warfare Center, Aircraft Division
Old MathSource #

Revision date


The functions Rule, Set, UpSet, TagSet each evaluate their right side immediately. If these functions have named patterns on the left side and the symbols used to name the patterns are needed on the right side then the global values of these symbols are used on the right side. To get the intended result you must ensure these symbols have no global values. This is demonstrated in the (LocalPatterns.nb) notebook.

The package (LocalPatterns.m) defines functions that work like Rule, Set, UpSet, TagSet but don't have the problem described above. All functions in the package are demonstrated and explained in the notebook (LocalPatterns.m).

LocalPatterns.m uses four special characters. A modified version of the BasicInput palette is provided to assist with entering the special characters. The modified palette is also explained in the (LocalPatterns.nb) package.

*Mathematica Technology > Kernel > Pattern Matching

Set, Rule, UpSet, TagSet, scope
Downloads Download Wolfram CDF Player

BasicInput2.nb (14.3 KB) - Mathematica palette [for Mathematica 5.0]
LocalPatterns.m (6.1 KB) - Mathematica package [for Mathematica 5.0]
LocalPatterns.nb (30.2 KB) - Mathematica notebook [for Mathematica 5.0]