MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

pattern match and formatting challenge

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68931] pattern match and formatting challenge
  • From: "Chris Chiasson" <chris at chiasson.name>
  • Date: Wed, 23 Aug 2006 07:16:04 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

I thought you might enjoy a pattern matching challenge and helping me
out at the same time. :-)

The challenge is, detect any expression that can be formatted as only
a linear sequence of unnested superscripts and subscripts. For bonus
"points", cause the expression to be formatted as mentioned here:

http://www.docbook.org/tdg5/en/html/equation.html

AFAIK, I have an expression that will do this, but only for a subset
of the possible expressions:

nonRowBoxBoxesPatternObject=Module[{x},Alternatives@@DeleteCases[ToExpression/@
	Cases[Names["System`*"],x_/;StringMatchQ[x,___~~"Box"]],RowBox]];

stringFormattableQ[expr_]:=FreeQ[ToBoxes[expr],nonRowBoxBoxesPatternObject];

If stringFormattableQ is true, then the formatting is done by via
ToString[expr].

-- 
http://chris.chiasson.name/


  • Prev by Date: Random numbers according to a rule / function
  • Next by Date: Re: Help !! problems with symbolize
  • Previous by thread: Re: Random numbers according to a rule / function
  • Next by thread: Re: pattern match and formatting challenge