People who code: we want your input. Take the Survey

Questions tagged [pattern-matching]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3
votes
2answers
95 views

Structural Pattern Matching syntax to match a value in a list

I was looking into Python 3.10's Structural Pattern Matching syntax, and I want to refactor one of my code that uses if-else, using structural pattern matching. My ...
2
votes
2answers
47 views

How to refactor the boolean logic of this F# function?

I have a list of path I want to filter out. I want to keep only paths matching a specific pattern and remove all paths matching another specific pattern. To achieve this I pattern matched on each ...
3
votes
1answer
107 views

strstr implementation with python and sets

Please review my strstr implementation in terms of time/space efficiency and overall readability. I am preparing for a coding assessment coming up as I am looking to pivot my career from Physics to ...
1
vote
1answer
47 views

Match Multiple Patterns in 2D Array and Return (x,y) Coordinates of the highest pattern

Problem Description We are given 2 arrays: 1 array representing the image and containing the patterns to be match and another one representing the pattern. Each image is represented as an vector ...
5
votes
4answers
262 views

Check if a given string matches a wildcard pattern

I'm trying to optimize my solution to the following question: given a regular expression with chars and special char '*', (star which is a joker we can replace with any string), and a string, write a ...
6
votes
2answers
152 views

Separating data from string representation of objects, with added extras

Given a string representation of data, I want to extract the information into its corresponding object. However, If the string has "|" separators then these should be considered options and ...
1
vote
0answers
126 views

Idiomatic Rust matches with pattern guards

I'm quite new to Rust, and am working on a virtual machine image decompiler. I have some working code that uses match to check opcode numbers, but it doesn't feel ...
4
votes
1answer
776 views

Rust Beginner: flatten nested matches

This is how I implemented the guessing game - chapter 2 of the Rust book: https://doc.rust-lang.org/book/ch02-00-guessing-game-tutorial.html ...