Pattern matching

Japanese: パターンマッチング - ぱたーんまっちんぐ(英語表記)pattern matching
Pattern matching

A term used in symbolic processing to refer to a method of detecting specific patterns when searching data or strings. In programming languages, it is also used to match structured data.

Regular expressions are defined to describe string patterns. Some of them are shown below.

. (period) any one character * (asterisk) any number of repetitions of the preceding character (writing . * matches a string of any length)
[xyz] Any character in [ ] (in this example, x, y, or z)
[az] Specifies a character range (in this example, any lowercase alphabetic character)
For example, [ac]. * x
will match strings that start with a, b, or c and end with x (such as abx, b123x, cdx, etc.).

Prolog is a language that does not use strings, but is invoked by pattern matching of structures called terms. Capital letters represent variables and lowercase letters represent constants, so p(X,z,X)
The terms are p(a,z,a),p(b,Y,b), and p(q(a),z,q(a)).
etc.

[Hideyuki Nakajima September 17, 2019]

[Reference] | Programming Languages | Prolog

Source: Shogakukan Encyclopedia Nipponica About Encyclopedia Nipponica Information | Legend

Japanese:

記号処理において使われる用語で、データや文字列を検索する際に特定のパターンを検出する手法のこと。プログラミング言語では構造をもったデータどうしのマッチングにも使われる。

 文字列のパターンを記述するための正規表現が決められている。以下に一部を示しておく。

 . (ピリオド)任意の1文字
 *(アスタリスク)直前の文字の任意個の繰り返し(.*と書くと任意の長さの文字列にマッチする)
 [xyz]   [ ]内のどれかの文字(この例ではxかyかz)
 [a-z]   文字範囲の指定(この例では任意のアルファベットの小文字)
 たとえば
 [a-c].*x
はa,b,cのどれかで始まり、xで終わる文字列(abx, b123x, cdxなど)とマッチする。

 Prolog(プロログ)は文字列ではないが、項とよばれる構造のパターンマッチングで呼び出される言語である。大文字で変数を表し、小文字が定数なので
 p(X,z,X)
という項は
 p(a,z,a),p(b,Y,b), p(q(a),z,q(a))
などとマッチする。

[中島秀之 2019年9月17日]

[参照項目] | プログラム言語 | Prolog

出典 小学館 日本大百科全書(ニッポニカ)日本大百科全書(ニッポニカ)について 情報 | 凡例

<<:  Hachi (bee) - bee

>>:  Hatanpo - Hatanpo (English spelling) sweepers

Recommend

Clonal selection theory - Clone selection theory

This is the current mainstream theory of the immun...

The Dawn of European Civilization

…Born in Sydney, he graduated from the University...

Silk thread spinning - Chushiboseki

A type of silk spinning method. It is a regenerati...

Bee Gees

...The word "discotheque" originally me...

Kusaira - Kusaira

…It originated as a military camp (Misr) built in...

Epipactis papillosa (English spelling)

… [Ken Inoue]. … *Some of the terminology that me...

Collateral - Tampo

In a broad sense, it means a promise not to cause...

Kisei Main Line - Kisei Main Line

The name of the JR line that runs along the coast...

Liparis nervosa (English spelling) Liparisnervosa

… [Ken Inoue]. … *Some of the terminology that me...

Red-winged Ornithoptera - Red-winged Ornithoptera

…In 1978, the Papua New Guinea government banned ...

Small cargo - Konida

〘 noun 〙① Baggage carried by horses during marches...

Red ground brocade

…There are also varieties such as Kiyohime, Tamah...

Space Hydrogen Bomber Battle

...The intense primary color effects of the red a...

time charter

…In the broad sense, chartering refers to both th...

Edo Kaimai - Edo Kaimai

…At the same time, rice began being transported f...