0
|
5171 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:
GROUPS:

# Pattern replacement rule - how to eliminate extra step

Posted 11 years ago
 This one should be fairly easy for any Mathematica programmer:I haveGP = GeoPoint[Name_, {East_Real, North_Real}, Elev_Real];GP // FullFormand need to get rid of al the patterns in order to use the expression on the rhsThis works:GP /. Pattern -> axa% /. axa[n_, _] -> nand produces the desired output:GeoPoint[Name, {East, North}, Elev]Now - how do I get rid of the extra step?The problem is that Mathematica is evaluating the Pattern and I don't know how to tell it not to do so - I can't figure out how to use any of the Hold, HoldPattern, HoldAll, HoldComplete etc constructs
3 Replies
Sort By:
Posted 11 years ago
 Wrapping the pattern expression head Pattern in Verbatim is the type of hold you are looking for.In[ ]:= GP /. Verbatim[Pattern][p_, _] :> pOut[ ]= GeoPoint[Name, {East, North}, Elev]
Posted 11 years ago
 Merci Iliane! Super e!
Posted 11 years ago
 How about In[4]:= GP /. p_Pattern :> First[p]Out[4]= GeoPoint[Name, {East, North}, Elev]
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments