Questions tagged [pattern-matching]
Finding sequences of data that have a particular structure or matching specific criteria or rules. For character pattern defined by a regular expression, use the tag regular-expressions instead.
36 questions
2
votes
5
answers
3k
views
Pattern Matching on Request Body for Routing an HTTP Request
In an HTTP application, I think about routing requests based not only on the path, but also based on the request body. For an example, think about the following two different body schemas for a PUT ...
0
votes
1
answer
122
views
Matching supersets
In my application I have requests and items, each of which are associated with property tuples (key value pairs, where keys can be repeated) stored in a Postgres database.
The goal is to find a single ...
0
votes
1
answer
90
views
Extending TypeScript while being futureproof [closed]
C#10 Has extended the property pattern ability, I think it began since #7
EG:
{ Car: { Interior: pattern } }
Meaning you can do some nice pattern matching even in if statements
if (car_var is ...
5
votes
4
answers
243
views
Are there known constructs for two-way string pattern matching?
I've often come across situations where pattern matching in a string is formalized, but the reverse is not.
Say I invent a new string pattern that can be expressed by regex /([0-9a-z])*:([0-9a-z])*@([...
2
votes
2
answers
3k
views
How to find matching profiles?
I'm developing backend for a dating app, in which each user has
a profile of his/her characteristics
a profile of ideal match's characteristics
There are dozens of characteristics like gender, ...
2
votes
2
answers
396
views
Pattern Matching in OO code
I have a situation where I need to model objects that don't share common attributes but represent same logical entity. Now, based on their type they will have different attributes (properties).
To ...
1
vote
1
answer
63
views
Managing cache when matching datas
I'm retrieving values from 3 tables in database and trying to make them match. I was wondering how I could manage cache in an elegant way. I can't change the database structure even though one of the ...
2
votes
1
answer
156
views
Architectural considerations for frequently matching similar users
I've been trying to design a backend architecture to a SPA that satisfies the following:
user constantly answer yes/no questions (ex: tinder swipe cards)
The application calculates each user's ...
0
votes
1
answer
272
views
Sequence matching problem is complicated, how can I break it down into easier smaller pieces?
I have two lists:
1:
1) A abc
2) A def
3) A ghi
4) B jkl
5) B mno
6) C fzy
7) C xxa
2:
1) vsf
2) jkl
3) fzy
4) xxa
5) xyz
6) mno
7) def
8) abc
I am trying to match each of the continuous sequences ...
3
votes
1
answer
5k
views
Best method for Pattern Matching on Binary String?
I need to search a long string of binary string data (couple of megabytes worth of binary digits) for patterns of binary digits. There are about 100 000 different patterns to search for. Each is a ...
5
votes
2
answers
1k
views
Avoiding instanceof for recursive data types
I have written a simple class hierarchy to represent terms in Scala. Terms are recursive data types, e.g., a Sum and a Multiplication consist of the left-hand-side (lhs), which is a Term, and the ...
1
vote
5
answers
2k
views
Representing different method results via the return type in C#
I am looking at a problem where a method can fail in a predictable way. For now I think that exceptions might not be a good way to represent some of the failures (I may be wrong on that). In any case ...
6
votes
3
answers
3k
views
Search for similar vectors, based on elementwise difference
I understand that there is a thread discussing a similar issue here:
How to efficiently search a set of vectors for a vector which is the closest match
But my problem is slightly different - and ...
2
votes
0
answers
197
views
combine reader monad with choice
I have this two types
open FSharpx
open FSharpx.Reader
type First =
{ Name: string
Items: string list }
type Second =
{ Name: string
Numbers: int list }
Using a Reader monad ...
2
votes
1
answer
130
views
F# - Associating a function with the matching type of object
Let's say I'm programming a chess game. At some point I have to check, which moves are valid for a given piece. What would be the proper way to select the correct pathfinding function for a given ...