What is 'Pattern Matching' in functional languages?

后端 未结 9 541
栀梦
栀梦 2020-11-30 16:43

I\'m reading about functional programming and I\'ve noticed that Pattern Matching is mentioned in many articles as one of the core features of functional languages.

9条回答
  •  心在旅途
    2020-11-30 17:10

    You should start with the Wikipedia page that gives a pretty good explanation. Then, read the relevant chapter of the Haskell wikibook.

    This is a nice definition from the above wikibook:

    So pattern matching is a way of assigning names to things (or binding those names to those things), and possibly breaking down expressions into subexpressions at the same time (as we did with the list in the definition of map).

提交回复
热议问题