Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • $\begingroup$ Faster and more elaborate than mine -- of course :-) $\endgroup$ Commented Feb 23, 2012 at 16:27
  • $\begingroup$ @Albert You should remove this "of course" - I was faster by pure luck, and your solution is simpler. $\endgroup$ Commented Feb 23, 2012 at 16:28
  • $\begingroup$ You should also include Optional in your parser as it wraps Pattern like PatternTest does, e.g. FullForm[HoldPattern[a_:0]] returns HoldPattern[Optional[Pattern[a, Blank[]],0]. $\endgroup$ Commented Feb 23, 2012 at 16:35
  • $\begingroup$ @Leonid: I just deleted mine, since it just is a simpler version of yours. You might want to add an explanation that SetDelayed@@Hold[...] is just a trick to avoid the localization of SetDelayed that was the root of the problem that Ian has seen. $\endgroup$ Commented Feb 23, 2012 at 16:37
  • $\begingroup$ @rcollyer Yes, you are right. Actually, the parser itself is not written well, because it should be true recursive decsent, while I took a short-cut and substituted it with repeated rule application through ReplaceRepeated. I will take some time and rewrite it, then update the answer - and incorporate your suggestion as well. $\endgroup$ Commented Feb 23, 2012 at 16:39