Pattern Matching

In computer science, pattern matching is the act of checking a perceived sequence of tokens for the presence of the constituents of some pattern. In contrast to pattern recognition, the match usually has to be exact. The patterns generally have the form of either sequences or tree structures. Uses of pattern matching include outputting the locations (if any) of a pattern within a token sequence, to output some component of the matched pattern, and to substitute the matching pattern with some other token sequence (i.e., search and replace).

Sequence patterns (e.g., a text string) are often described using regular expressions and matched using techniques such as backtracking.

Tree patterns are used in some programming languages as a general tool to process data based on its structure, e.g., Haskell, ML and the symbolic mathematics language Mathematica have special syntax for expressing tree patterns and a language construct for conditional execution and value retrieval based on it. For simplicity and efficiency reasons, these tree patterns lack some features that are available in regular expressions.

Often it is possible to give alternative patterns that are tried one by one, which yields a powerful conditional programming construct. Pattern matching sometimes include support for guards.

Term rewriting and graph rewriting languages rely on pattern matching for the fundamental way a program evaluates into a result.

Read more about Pattern MatchingHistory, Primitive Patterns, Tree Patterns, Filtering Data With Patterns, Pattern Matching in Mathematica, Pattern Matching and Strings

Other articles related to "pattern matching, patterns, pattern":

Conditional (computer Programming) - Choice System Cross Reference
... Programming language Structured if switch/select/case Arithmetic if Pattern matching then else else-if Ada Yes Yes Yes Yes No No C/C++ Yes Yes unneeded fall-through No No C# Yes Yes unneeded Yes No No ... is unneeded, because the same task can be done with pattern matching ...
Refal
... Unlike Lisp, Refal is based on pattern matching ... Its pattern matching works in the forward direction rather than backwards (starting from the goal) as in Prolog ... Refal lists are built and scanned from both ends, and pattern matching allows to match against nested lists as well as the top-level one ...
Pattern Matching and Strings - SNOBOL
... from most programming languages by having patterns as a first-class data type (i.e ... permitted to any other data type in the programming language) and by providing operators for pattern concatenation and alternation ... SNOBOL4 patterns, however, subsume BNF grammars, which are equivalent to context-free grammars and more powerful than regular expressions ...
Scala (programming Language) - Features (with Reference To Java) - Functional Tendencies - Case Classes and Pattern Matching
... Scala has built-in support for pattern matching, which can be thought as a more sophisticated, extensible version of a switch statement, where arbitrary data types can be matched (rather than just simple types ... as a case class is provided, which includes automatic support for pattern matching and can be used to model the algebraic data types used in many ... and hashing, and destructuring a case class on its constructor parameters during pattern matching.) An example of a definition of the quicksort algorithm using pattern matching is as follows def qsort(list List ...
Kasian Franks - Career
... Franks worked as software engineer and product developer specializing in pattern matching algorithms and tools for companies and organizations such as Sun Microsystems ... Franks began to study biomimetics along with pattern matching in data and nature ... a music search, discovery and pattern matching company in which the U.S ...

Famous quotes containing the word pattern:

    A two-week-old infant cries an average of one and a half hours every day. This increases to approximately three hours per day when the child is about six weeks old. By the time children are twelve weeks old, their daily crying has decreased dramatically and averages less than one hour. This same basic pattern of crying is present among children from a wide range of cultures throughout the world. It appears to be wired into the nervous system of our species.
    Lawrence Kutner (20th century)