Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

-2
votes
0answers
33 views

Design Pattern for Data Enrichment vs Similarity Matching [duplicate]

I have some things (JSON) coming from various sources (Search engine, Crawled HTML, APIs...). I'm trying to match similar things from the different sources as follows: [1] Collect -> [2] Prepare -&...
1
vote
2answers
180 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
2answers
146 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
1answer
45 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
1answer
101 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
1answer
189 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 ...
3
votes
1answer
1k 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
2answers
617 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
5answers
1k 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 ...
5
votes
3answers
810 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
0answers
164 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
1answer
86 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 ...
3
votes
1answer
86 views

Pattern matching events with arbitrary structure

My team implemented an alert broker system. The way it works is this: Event sources generate events, with mostly arbitrary structure, and the broker listens to them. Users go to the broker and use an ...
2
votes
0answers
130 views

String Pattern Matching from Lookup Table - Non-Exponential Solution?

Given the problem... Given a String comprising of non-alhpabetical symbols, and a Lookup Table where a subset of those symbols may equate to a single alphabetical character, output all possible ...
9
votes
5answers
3k views

Idiomatic pattern matching equivalent in Java

I'm building a simulator which parses some events from STDIN and "runs" them. My background is mostly functional programming these days, so it seemed natural to do something like this: data Event = ...
4
votes
3answers
412 views

How to report multiple errors as a result of validation?

I have a class that transforms a complex model, for example an abstract syntax tree or intermediate model. The model can be either valid, invalid or partially invalid, i.e. it contains errors but some ...
0
votes
1answer
17 views

Comparing articles from various web-stores

Today I had the idea to write a program that compares the prizes between different web-stores. The key question I am asking myself is how to find (with a high probability) the same article on another ...
3
votes
2answers
154 views

Algorithm to identify degree of similarity based on prior categorization

I am working with digital images that people have manually categorized on a number of parameters. I want to be able to find images that are similar or dissimilar based on certain categories. For ...
1
vote
2answers
136 views

Multi-pattern matching

I have a given byte array in C and I need to match it against several byte arrays and return true if there is any match. I can make various memcmp's but I feel that it is very inefficient. Do you ...
4
votes
1answer
227 views

Pattern matching against two similar types

What is the best way to handle pattern matching in the following situation? sealed trait Metadata final case class Metadata1() extends Metadata final case class Metadata2() extends Metadata final ...
1
vote
1answer
77 views

Why try to match for nth negatives, as opposed to matching lesser positives?

My Title clearly indicated my lack of understanding about the core concept for pattern matching - specifically using .HTACCESS to block Bad-Bots from accessing a site, which they do in order to crawl ...
1
vote
1answer
150 views

Measure and locate areas of similar value in an image

I saw this picture online and wanted to see if I could create an algorithm to give ordinary images an effect like this: http://justinlivi.net/wp-content/uploads/2011/01/Living_In_Digital.jpg My idea ...
10
votes
2answers
2k views

Why can't the Scala compiler give pattern matching warning for nonsealed classes/traits?

If I use an unsealed trait or abstract class in Scala and then use pattern matching, I wonder, does the compiler not know at compile time for this particular patternmatch what possible implementations ...
0
votes
4answers
675 views

Haskell's ':' operator

I am currently studying about pattern matching in Haskell from here. The author gives an example of the implementation of "head" function (which returns the first element of a list) as following: ...
3
votes
1answer
314 views

Efficient Code Design for Pattern Search Using a Singleton Pattern

I am having difficulty figuring out an efficient (thread-safe) code design for the following problem. I have been at it for some time now and would really appreciate some advice and input on how best ...
7
votes
1answer
2k views

How do you make decorators as powerful as macros?

Quick background: I am designing a Pythonic language that I want to be as powerful as Lisp while remaining easy to use. And by "powerful", I mean "flexible and expressive". I've just been introduced ...
12
votes
1answer
8k views

Pattern matching in Clojure vs Scala

What are the key differences between pattern matching in these two languages? I am not referring to syntax, but capability, implementation details, range of use cases and necessity. Scala ...
16
votes
4answers
4k views

Is pattern-matching against types idiomatic or poor design?

It seems like F# code often pattern matches against types. Certainly match opt with | Some val -> Something(val) | None -> Different() seems common. But from an OOP perspective, that looks ...
5
votes
2answers
380 views

Is it possible (and practical) to search a string for arbitrary-length repeating patterns?

I've recently developed a huge interest in cryptography, and I'm exploring some of the weaknesses of ECB-mode block ciphers. A common attack scenario involves encrypted cookies, whose fields can be ...
6
votes
2answers
3k views

Data structure for pattern matching

Let's say you have an input file with many entries like these: date, ticker, open, high, low, close, <and some other values> And you want to execute a pattern matching routine on the entries(...
1
vote
1answer
583 views

How to implement string matching based on a pattern

I was asked to build a tool that can identify if a string match a pattern. Example: {1:20} stuff t(x) {a,b,c} would match: 1 stuff tx a 20 stuff t c It is a sort of regex but with a different ...
1
vote
3answers
2k views

Programming language with pattern matching in trees [closed]

I'd like to prototype a computer algebra system. An equation would be represented by a tree and rules would be defined - similarly to mathematical axioms - by specifying a pattern (in the tree) and a ...
3
votes
1answer
2k views

Tineye.com search algorithm?

I was wondering how does tineye carry a search. Does it store all the images and then extracts exif data? Which in turn must be stored in a database and queried against. So probably it is using some ...