Skip to main content
Filter by
Sorted by
Tagged with
Advice
0 votes
3 replies
67 views

I'm not yet very familiar with the patterns in Lua's string.gsub function. If I have a string like this: Fishing Lure(+100 Fishing Skill)(1 hour) and I want extract only the string "1 hour"...
user3204810's user avatar
0 votes
1 answer
142 views

Edit: added a second part of the question below. I am getting the error "borrow of moved value" here, but the thing being moved is an &mut Containee, so I didn't expect it to cause a ...
knutaf's user avatar
  • 113
9 votes
1 answer
152 views

JEP 455 introduced Primitive Types in Patterns, instanceof, and switch as a preview feature in JDK 23. It continues as a preview feature in JDK 24 and 25, so the feature is not detailed in the Java ...
Speakjava's user avatar
  • 3,510
2 votes
1 answer
69 views

I have a query in PostgresSQL accessing a big table using a LIKE clause for pattern matching: Table "rmx_service_schema.document" ...
Pulsedriver's user avatar
1 vote
1 answer
142 views

I am looking for pattern matching in GridDB using NewSQL to return values true when matched and false when not matched. The string can start with 91 followed 33 followed by 8 digit number followed by ...
sayana_dutta's user avatar
0 votes
1 answer
85 views

Is there a construct which allows to drop the repetition of the 0.0 routine below val price: Option[Double] = ??? price match { case Some(d) => if (isPriceFair(d)) d else ...
IUnknown's user avatar
  • 9,987
1 vote
1 answer
113 views

class Person( id:String , age:Option[Double]) val rows: Seq[Person] = List(Person("a",None),Person("c",None),Person("e",50)) val ages = rows.foreach( r => r.age ...
IUnknown's user avatar
  • 9,987
-2 votes
1 answer
106 views

I am trying to do some inventory management, I have a list of catalog numbers of materials we need and a list of managed stock onsite. I have a vector of catalog numbers (num) which are accurate to ...
AudileF's user avatar
  • 462
1 vote
1 answer
122 views

In a parser library I maintain, I have some classes that inherit from str to manage parsed strings and parsed symbols. This has been working well for a long time, but with Python 3.10, someone ...
Joshua D. Boyd's user avatar
1 vote
1 answer
63 views

In the example, there is a "match redundant" Error, indicating that SOME s is matching on every string and not the provided s: fun matchs (s : string) : (string option -> bool) = fn x =&...
qwr's user avatar
  • 11.6k
3 votes
6 answers
158 views

I have over forty files with the following structure: file1 first 21 lines 8191 M0 139559 M1 79 M10 1 M10007 1 M1006 1 M10123 file2 first 21 lines 8584 M0 119837 M1 72 M10 1 M10003 1 M10045 1 M1014 ...
Matteo's user avatar
  • 435
0 votes
0 answers
43 views

There is an example in the official book: let x = 2; match x { e @ 1 ..= 5 => println!("got a range element {}", e), _ => println!("anything"), } What's the point ...
Shtole's user avatar
  • 367
2 votes
0 answers
110 views

I am using Microsoft® Excel® 2019 MSO (バージョン 2504 ビルド 16.0.18730.20122) 32 ビット and made MACRO as under If Range(HotelCol & Row).Value Like "*" & HTLArray(HtlRmNtRow) & "*&...
F Otake INPAC's user avatar
3 votes
2 answers
131 views

Given a list of objects to be passed to a method with overloads, I want to determine what overload best matches the object types in order to invoke that method. string TheMethod(string? foo, string? ...
Jeff Mercado's user avatar
4 votes
1 answer
201 views

I have access to a function bool getState(int x, int y, int z) that returns the value of a infinite 3D boolean array, conceptually shaped as [∞][4][∞]. That is, the Y dimension is limited to 4, but X ...
IIpho3nix's user avatar
0 votes
2 answers
137 views

If I have a StringValues, with following possible values: "AString" ["OnlyString"] ["FirstString", "IDontCare"] How can I use C# pattern matching to extract a ...
Giulio Caccin's user avatar
4 votes
0 answers
58 views

Why is it that if I switch on an Int16[] in C#, it will match with UInt16[], even when an Int16[] is present later in the switch statement? Example Code: namespace SwitchError; internal class Program ...
Salt92's user avatar
  • 49
0 votes
1 answer
101 views

I am using SWiftui and Xcode 16.2 and I am trying to get a region but getting this error . I have been searching around to see how I can resolve this but no luck 'let' binding pattern cannot appear in ...
user1591668's user avatar
  • 2,935
0 votes
1 answer
79 views

Is there a way to label a subexpression of a pattern so that the name can be reused? Consider: fn parse(all_toks : Vec<Token>) -> ParseResult<Form> { match all_toks { [ ...
Dennis's user avatar
  • 2,624
0 votes
2 answers
116 views

I have the following python code that converts an object into a view-like mapping. from collections.abc import Mapping class ObjView(Mapping): def __init__(self, obj): self.obj = obj ...
Keplerto's user avatar
  • 121
0 votes
1 answer
55 views

Let's say I have this part of a pattern match: (define/match (make lst) [((list)) (const #f '())] [((list (cons _ n))) (cons (make-tree-node n) '())] [((list-rest (cons parent pnum) (cons child ...
primfaktor's user avatar
  • 3,039
2 votes
1 answer
160 views

I have a lot of queries using ... WHERE company_id = 2 AND unaccent(name) ILIKE unaccent('value'); Is possible to create a index to optimize this type of query? I take a look at GIN and pg_trgm but ...
Max Bündchen's user avatar
0 votes
1 answer
58 views

I encountered some errors with pattern matching. For quasi-quote, the "ooo" pattern including "..." does not work. I looked at source code "guile-3.0.10/module/ice-9/match....
jcnn's user avatar
  • 13
-1 votes
1 answer
143 views

Wrt to Java pattern matching (JEP 441), if I am matching an object using a switch statement, like this: switch (cases) { case A( B b, C c, D d, ) -> doSomething(); } ...
Neil's user avatar
  • 168
0 votes
1 answer
111 views

The pattern [] only matches empty lists, while [_] only matches lists with exactly one element ([_,_] for exactly two elements and so on). So far it is logical for me. But it seems the patterns [..] ...
codymanix's user avatar
  • 29.6k
2 votes
1 answer
102 views

I have a Rust [i32; 6] that I'd like to split into three [i32; 2]. Can this be done by pattern matching, or do I explicitly have to reference all six elements? I'd like to do something like this: let ...
BallpointBen's user avatar
  • 15.6k
7 votes
1 answer
149 views

JDK 7 added support for String with a switch, which extended the list of types supported by switch. As of Java 7, a switch supported the primitive types byte, short, char, and int, their respective ...
Arvind Kumar Avinash's user avatar
0 votes
1 answer
69 views

Can we use fields of a pattern-matched enum variant to fill the fields of another variable of the same type? In other words, is it possible to make the following code work? #[derive(Debug)] enum Enum {...
PrinceOfBorgo's user avatar
3 votes
4 answers
124 views

I have a string of text and a vector of words: String: "Auch ein blindes Huhn findet einmal ein Korn." Vector: "auch", "ein" I want to check how often each word in the ...
Ben's user avatar
  • 821
0 votes
1 answer
62 views

I have this pattern [a-z0-9.+-_%]+@[a-z.-]+\.[a-z]{2,}$ that's supposed to only allow letters a-z. and - in the domain name of an email (after @ and before .), but inputting [email protected] is ...
bunsellerboy's user avatar
5 votes
1 answer
161 views

Raku has an interesting and exciting recursive-regex notation: <~~>. So in the REPL, we can do this: [0] > 'hellohelloworldworld' ~~ m/ helloworld /; 「helloworld」 [1] > '...
jubilatious1's user avatar
  • 2,473
1 vote
1 answer
85 views

All examples tested using Python 3.13.2 on Windows 10. When calling range(), I must use positional arguments, or otherwise I get an exception. >>> range(2, 5) range(2, 5) >>> range(...
Qba23's user avatar
  • 11
2 votes
0 answers
88 views

This question is a little complicated, so I try to describe it through an example. First, we get a string foo, and put it into collection S. Then we get a string sample, and put it into S too. Next, ...
differentrain's user avatar
1 vote
1 answer
71 views

I have a database with three columns: name, occupation, and organization. In these columns, I have duplicates with slightly different names. For example, Anne Sue Frank and Anne S. Frank refer to the ...
Vitoria Sanchez's user avatar
0 votes
0 answers
30 views

I’m exploring the new match statement introduced in Python 3.10. I want to learn how to parse JSON strings or YAML. Here’s the specific problem: The configuration structure can vary significantly ...
Arash's user avatar
  • 13
5 votes
2 answers
423 views

I would like to write an R function that takes a string as input, checks if several thousand substrings are present in that string, and returns a vector of substrings found in the tested string. I ...
TiredSquirrel's user avatar
0 votes
0 answers
40 views

I did an oopsie and made an infinite loop at the match case in the end: import pyautogui import cv2 import numpy as np import time def find_image(image_path, confidence=0.8): screenshot = ...
Giandalf's user avatar
2 votes
1 answer
77 views

Is it possible with sympy Wild symbols and replace to match arbitrary function applications? What I would ideally like to do is the following: x = Symbol('x') expr1 = sin(x) expr2 = exp(x) F = Wild('F'...
Robert Wegner's user avatar
1 vote
1 answer
113 views

I'm looking to parse a string that can be in one of the following formats: "[a]" "[a-b]" "[a-b/9]" "[a-b, b-c]" "[a-b/9, b-c]" In words, the part ...
Abhijit Sarkar's user avatar
0 votes
3 answers
92 views

I saw below code: let () = assert (f input1 = output1) The assert expression returns a value of type unit, which has only one possible value displayed as (). My understanding is, the let definition ...
smwikipedia's user avatar
-1 votes
1 answer
50 views

How to read numbers between pattern? Input string: ([\\S\\s]{8}))([\\S\\s]{20}))([\\S\\s]{10})) Output should be: 8 20 10 Note: opening and closed parenthesis are not fixed but it will be in pairs.
Sam Harris 's user avatar
0 votes
1 answer
166 views

In Hitchiker's Guide to Logical Verification (2023 Standard Edition) Ch. 2, p. 16, we have this -- "The general format of recursive definitions is: def name (params1 : type1) . . . (params-m :...
Igott's user avatar
  • 27
1 vote
1 answer
81 views

Background For simplicity, just using ADD as an example. In compiler backend, multiple addition is organized by combinations of multiple ADD instructions. For example ADD(1, ADD(1,3)). But since it is ...
Shore's user avatar
  • 1,059
0 votes
0 answers
46 views

I’m working on a project where I need to generate Perlin noise and match it with a binary (black & white) image. I want to find the Perlin noise pattern that best matches the input image in terms ...
Frederick's user avatar
0 votes
1 answer
154 views

I am building a program to help count the number of distinct codes that occur in multiple PDFs. I have got the data from the PDFs, that's not a problem. I just need to filter the lines based on ...
figgyfarts's user avatar
1 vote
1 answer
66 views

I have the following definitions in my Haskell code: -- A region has a list of squares, and a list of possible combinations of values, -- all of which add up to the same total. data Region = Region [...
Jeremy Hicks's user avatar
0 votes
1 answer
97 views

Noob to Rust and trying to figure out the idomatic way to decrement the value from a hashmap and remove the corresponding key when the value after decrementing reaches 0. I am doing it like this but ...
nunam's user avatar
  • 47
1 vote
2 answers
84 views

I am trying to use enum variants to store variables specific to tabs in an app. I am using the below code to extract the variable out of the enum. (because accessing a variant directly doesn't work, ...
LeaG's user avatar
  • 53
7 votes
1 answer
240 views

Here's a minimal reproduction for an issue I was having in a larger codebase: enum A<'b> { A1(&'b u8) } fn consume_fnmut(_f: &mut impl FnMut (A)) {} // Desugared: // fn ...
ais523's user avatar
  • 2,384
3 votes
1 answer
151 views

EDIT: this question is based on a faulty premise. Turns out that this was a false-positive from my IDE; the code is perfectly valid. See answer below. In rust, I'm a little confused about the ...
Aaron's user avatar
  • 7,145

1
2 3 4 5
156