Pattern Matching is an actively used design pattern created in 1960. In computer science, pattern matching is the act of checking a given sequence of tokens for the presence of the constituents of some pattern. In contrast to pattern recognition, the match usually has to be exact: "either it will or will not be a match." 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). Read more on Wikipedia...

59Years Old
  • Pattern Matching ranks in the top 25% of entities I track
  • the Pattern Matching wikipedia page
  • Pattern Matching first appeared in 1960
  • Have a question about Pattern Matching not answered here? Email me and let me know how I can help.

Languages with Pattern Matching include coconut, felix, haskell, hope, npl-lang

Example from coconut:

match [head] + tail in [0, 1, 2, 3]:
   print(head, tail)

Example from felix:

match x with
 | Some x => println$ x; 
 | None => println "NONE";

Example from haskell:

fib 0 = 1
fib 1 = 1
fib n | n >= 2
      = fib (n-1) + fib (n-2)

Last updated August 9th, 2020

Edit Pattern Matching on GitHub