Top "Pattern-matching" questions

Use this tag for questions about testing whether a data structure has a particular shape or contains particular values in certain locations.

Scala pattern matching confusion with Option[Any]

I have the following Scala code. import scala.actors.Actor object Alice extends Actor { this.start def act{ loop{ react { …

scala pattern-matching actor unchecked
Haskell: Parse error in pattern

Who likes to tell me what is wrong with this code (syntactically)? -- merge two sorted lists mergeX [] b res = …

haskell pattern-matching operator-precedence parse-error
Catching multiple exceptions at once in Scala

How to catch multiple exceptions at once in Scala? Is there a better way than in C#: Catch multiple exceptions …

exception scala exception-handling pattern-matching try-catch
RegExp match repeated characters

For example I have string: aacbbbqq As the result I want to have following matches: (aa, c, bbb, qq) I …

python regex pattern-matching
How can I detect common substrings in a list of strings

Given a set of strings, for example: EFgreen EFgrey EntireS1 EntireS2 J27RedP1 J27GreenP1 J27RedP2 J27GreenP2 JournalP1…

algorithm pattern-matching
Find common prefix of strings

I am having 4 strings: "h:/a/b/c" "h:/a/b/d" "h:/a/b/e" "h:/a/c" I …

c# string pattern-matching
How do I match multiple arguments?

I have a function: def func(a: int, b: int, c: double): int And I want to match various possible …

scala pattern-matching
Pattern matching string prefixes in Haskell

Let's say I want to make a special case for a function that matches strings that start with the character …

haskell pattern-matching
The argument types of an anonymous function must be fully known. (SLS 8.5)

I have a function literal {case QualifiedType(preds, ty) => t.ty = ty ; Some((emptyEqualityConstraintSet,preds)) } Which results in an …

scala lambda pattern-matching function-literal
Haskell pattern matching - what is it?

What is pattern matching in Haskell and how is it related to guarded equations? I've tried looking for a simple …

haskell functional-programming pattern-matching