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.

String pattern matching best practice

Following is the code that doesn't work but it describes what I want to do. Could you please recommend the …

scala pattern-matching
How to match accented characters with a regex?

I am running Ruby on Rails 3.0.10 and Ruby 1.9.2. I am using the following Regex in order to match names: NAME_…

ruby-on-rails ruby regex ruby-on-rails-3 pattern-matching
How to generate a number sequence in file using vi or Vim?

Is there a way to generate a number sequence in vi or Vim? For example, for an arbitrary range of …

vim pattern-matching vi sequential
KMP prefix table

I am reading about KMP for string matching. It needs a preprocessing of the pattern by building a prefix table. …

string algorithm data-structures pattern-matching
Why does pattern matching in Scala not work with variables?

Take the following function: def fMatch(s: String) = { s match { case "a" => println("It was a") case _ => println("…

scala pattern-matching match
How to compare enum without pattern matching

I want to apply filter on an iterator and I came up with this one and it works, but it's …

enums pattern-matching rust
Detecting an object on the image based on geometrical form

I have a basic understanding in image processing and now studying in-depth the "Digital Image Processing" book by Gonzales. When …

image-processing pattern-matching computer-vision pattern-recognition
Pattern matching of lists in Python

I want to do some pattern matching on lists in Python. For example, in Haskell, I can do something like …

python functional-programming pattern-matching
Is there a cleaner way to pattern-match in Scala anonymous functions?

I find myself writing code like the following: val b = a map (entry => entry match { case ((x,y), u) =&…

scala pattern-matching
Convert Scala List to List with another type

I want to create a more complex object type List from a simple type List. Eg, List[String] => List[…

list scala pattern-matching