Pattern matching: Difference between revisions

Content deleted Content added
Monkbot (talk | contribs)
m Task 18 (cosmetic): eval 7 templates: hyphenate params (3×);
adding references
Line 6:
Sequence patterns (e.g., a text string) are often described using [[regular expression]]s and matched using techniques such as [[backtracking]].
 
Tree patterns are used in some [[programming language]]s as a general tool to process data based on its structure, e.g. [[C Sharp (programming language)|C#]],<ref>{{cite web|url=https://docs.microsoft.com/en-us/dotnet/csharp/pattern-matching|title=Pattern Matching - C# Guide}}</ref> [[F Sharp (programming language)|F#]],<ref>{{cite web|url=https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/pattern-matching|title=Pattern Matching - F# Guide}}</ref> [[Haskell (programming language)|Haskell]], [[ML programming language|ML]], [[Rust (programming language)|Rust]],<ref>{{cite web |url=https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html |title=Pattern Syntax - The Rust Programming language}}</ref> [[Scala programming language|Scala]],<ref>{{Cite web|title=Pattern Matching|url=https://docs.scala-lang.org/tour/pattern-matching.html|access-date=2021-01-17|website=Scala Documentation}}</ref> [[Swift (programming language)|Swift]]<ref>{{cite web|url=https://docs.swift.org/swift-book/ReferenceManual/Patterns.html|title=Patterns — The Swift Programming Language (Swift 5.1)}}</ref> and the symbolic mathematics language [[Mathematica]] have special syntax for expressing tree patterns and a [[language construct]] for [[Conditional (programming)|conditional execution]] and value retrieval based on it.
 
Often it is possible to give alternative patterns that are tried one by one, which yields a powerful [[Conditional (programming)|conditional programming construct]]. Pattern matching sometimes includes support for [[guard (computing)|guards]].{{citation needed|date=January 2019}}