A technique commonly employed by functional languages (such as CAML, Haskell, SML and Miranda), allowing complicated control decisions based on data structure to be expressed in a concise manner. Typically, pattern matching constructs have an "else" clause or a wildcard symbol, so that the default case can be matched. For example, a "sum of all integers in an integer list" function in OCAML, where the ``_'' wildcard is used instead of the empty list:

let rec sum_all lst =
    match lst with
        head :: tail -> head + sum_all tail
        | _ -> 0;;

In a text processing context, pattern matching usually refers to a form of regexping or globbing.

Log in or register to write something here or to contact authors.