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

Pentecost Island

An island in the New Hebrides archipelago that for...

Field ion microscope - DENKAIONKENBIKYO

FIM is an abbreviation of FIM. It was invented by...

EMU - EMU

European Monetary Union : Economic and monetary in...

Eggplant

... In winter, it can be served with a thickened ...

Yancheng Province - Yancheng Province

…On the other hand, the local offices established...

Hierakonpolis (English spelling)

An ancient city on the west bank of the Nile, 80 k...

Popeye the Sailor

An American cartoon character. He is a powerful s...

Owari Yagyu School

One of the schools of swordsmanship. It was founde...

Pine heart moth - Dioryctria sylvestrella

An insect of the family Pyralidae in the order Lep...

Inula britannica

…[Hiroji Koyama]. . … *Some of the terminology th...

Chang'e

A woman who appears in ancient Chinese legends. A...

Chindonya - Chindonya

Advertising and promotion workers who walk around ...

Glycyrrhiza glabra (English spelling) Glycyrrhiza glabra

…[Mitsuru Hotta] [Aya Nitta]. … *Some of the term...

Abnormal day - Ijyoubi

...And this was named Singularität, or singularit...

Kyoya - Kyoke

[1] 〘Noun〙① A noble or aristocrat living in Kyoto....