💾 Archived View for station.martinrue.com › marginalia › db763f261b074ecb8b32191a0dc748a1 captured on 2023-05-24 at 20:48:37. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
Is there something like a regexp-language, except generalized to sequences of objects? I want to be able to express patterns of properties in a list, and find matches in a way that isn't if((foo(i j) && bar(i j 1) && baz(i j 2)) || foo(i j) && ...
2 years ago · 👍 aka_dude
@aka_dude Yeah, something like that. I'm specifically looking for a way of expressing a matcher against repeating patterns (like, with regexps), but matching against object properties. Basically, if you generalize regexps from character traits to object traits · 2 years ago
I see you want to match on Java objects. Maybe one could create something handy like monadic parser in Java, too · 2 years ago
Is this just parsing? Parser is something that takes stream of symbols (of any kind) and either returns an error or parsed object. In purely functional languages like Haskell parsing looks very nice (see monadic parsers, e.g. Megaparsec)
This "symbols" may not be characters/bytes, anything works · 2 years ago
My bad, 636 is the tutorial, it was 622/634. https://www.python.org/dev/peps/pep-0636/ · 2 years ago
Use a language with ML-style pattern matching. Python now supports this thanks to PEP 636. · 2 years ago
Perl/Raku · 2 years ago
No these are objects, like Java-objects, not strings. If they were strings I could just use regexp. I don't want to have to serialize them down to strings just so I can find repetitions :-( · 2 years ago
XPath/XQuery or jq? Assuming you can feed your list as XML or JSON. Or maybe encode your list as text and actually use regexps? · 2 years ago
(also, explicit state machines are an implicit surrender to the problem of finding a good abstraction) · 2 years ago