💾 Archived View for station.martinrue.com › marginalia › db763f261b074ecb8b32191a0dc748a1 captured on 2024-05-12 at 16:58:04. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-05-24)

🚧 View Differences

-=-=-=-=-=-=-

👽 marginalia

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

Actions

👋 Join Station

9 Replies

👽 marginalia

@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

👽 aka_dude

I see you want to match on Java objects. Maybe one could create something handy like monadic parser in Java, too · 2 years ago

👽 aka_dude

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

👽 mntn

My bad, 636 is the tutorial, it was 622/634. https://www.python.org/dev/peps/pep-0636/ · 2 years ago

https://www.python.org/dev/peps/pep-0636/

👽 mntn

Use a language with ML-style pattern matching. Python now supports this thanks to PEP 636. · 2 years ago

👽 mc

Perl/Raku · 2 years ago

👽 marginalia

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

👽 kevinsan

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

👽 marginalia

(also, explicit state machines are an implicit surrender to the problem of finding a good abstraction) · 2 years ago