💾 Archived View for station.martinrue.com › marginalia › db763f261b074ecb8b32191a0dc748a1 captured on 2023-04-20 at 01:03:31. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

➡️ Next capture (2023-05-24)

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

👽 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) && ...

1 year 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 · 1 year ago

👽 aka_dude

I see you want to match on Java objects. Maybe one could create something handy like monadic parser in Java, too · 1 year 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 · 1 year ago

👽 mntn

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

👽 mntn

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

👽 mc

Perl/Raku · 1 year 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 :-( · 1 year 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? · 1 year ago

👽 marginalia

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