Quantcast
Channel: Active questions tagged string-manipulation - Mathematica Stack Exchange
Viewing all articles
Browse latest Browse all 189

Intra-Symbolic Wild Card Pattern Matching

$
0
0

I have the following custom expression structure I am parsing:

Theorema`Knowledge`Q$TM[ Theorema`Language`VAR$[Theorema`Knowledge`VAR$x$TM]]

I already was able to match the inner structure so that I can just output the value x, like so:

parser[Theorema`Language`VAR$[a_]] :=     Module[{varName = SymbolName[Unevaluated[a]]},"\\VarTM{"<> StringReplace[varName, {"Theorema`Knowledge`VAR$" -> "", "$TM" -> ""}] <> "}"    ];

(Happy to hear if anyone has a more elegant way to achieve this!)

But in the previous parsing example, the structure is different from the predicate structure Theorema`Knowledge`Q$TM[] because there is no outside structure I can reference the inner one in terms of.

I want to achieve something like (this does not work):

parser[Theorema`Knowledge`symbol_ /; StringEndsQ[SymbolName[Unevaluated[Theorema`Knowledge`symbol]], "$TM"][a___]] := "Test2! "

Where my stand-in string take on the value of symbol, so "Q" in the example, meant to be generic predicate of some sort. Does anyone have an idea for how to do this kind of partial/intra-matching, with a wild card for my predicate name (maybe longer than just one letter, also)?


Viewing all articles
Browse latest Browse all 189

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>