RE:Controlling evaluation in Symbolize
- To: mathgroup at smc.vnet.net
- Subject: [mg30518] RE:Controlling evaluation in Symbolize
- From: Richard Gass <gass at physics.uc.edu>
- Date: Fri, 24 Aug 2001 20:58:12 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Following up on my original posting David Park and I wrote a function
SymbolizeSubscripts which allows you to effectively map Symbolize
across a list of of subscripts. A second function
RemoveSymbolizedSubscripts removes the symbols. The functions are
(they look horrible in email but can be cut and pasted into a
Mathematica notebook without trouble)
\!\(\(SymbolizeSubscripts::usage = \*"\"\<SymbolizeSubscripts[X, {a,b,c...}] \
will Symbolize \!\(X\_a\), \!\(X\_b\), \!\(X\_c\)... . SymbolizeSubscripts \
takes the option ReturnSymbols\>\"";\)\[IndentingNewLine]
\(ReturnSymbols::usage = "\<ReturnSymbols is an option to \
SymbolizeSubscripts. The default value of ReturnSymbols is False. If \
ReturnSymbols is True then SymbolizeSubscripts returns a list of the created \
symbols.\>";\)\[IndentingNewLine]
\(Options[
SymbolizeSubscripts] = {ReturnSymbols -> False};\)\[IndentingNewLine]
SymbolizeSubscripts[X_Symbol, \ sub_List,
opts___?OptionQ]\ := \[IndentingNewLine]Module[{symbols, heldsymbols,
optionvalue}, \n\ \ \ \ \ symbols\ =
Hold[Symbolize[
NotationBoxTag[
SubscriptBox[X,
subvar]]]]; \n\ \ \ \ \ heldsymbols\ = \n\ \ \ \ \ \ \ \
symbols\ /. \n\ \ \ \ \ \ \ \ \ Outer[
List, \n\ \ \ \ \ \ \ \ \ \ \ Partition[
Thread[subvar\ ->
ToString\ /@ sub], \n\ \ \ \ \ \ \ \ \ \ \ \ \ 1], \ {X\ ->
ToString[X]}]; \n\ \ \ \ \ ReleaseHold[
heldsymbols]; \[IndentingNewLine]optionvalue = \(ReturnSymbols /. \
{opts}\) /. Options[SymbolizeSubscripts]; \[IndentingNewLine]If[
optionvalue == True,
ToExpression[
Cases[heldsymbols, SubscriptBox[x_, y_], {0, \[Infinity]}]],
Null]]\)
\!\(\(RemoveSymbolizedSubscripts::usage = \
\*"\"\<RemoveSymbolizedSubscripts[X, {a,b,c...}] will fully remove the \
symbols \!\(X\_a\), \!\(X\_b\), \!\(X\_c\)...\>\"";\)\[IndentingNewLine]
RemoveSymbolizedSubscripts[X_Symbol,
sub_List] := \[IndentingNewLine]Module[{symbols,
heldsymbols}, \[IndentingNewLine]symbols\ =
Hold[RemoveSymbolize[
NotationBoxTag[
SubscriptBox[X,
subvar]]]]; \n\ \ \ \ \ heldsymbols\ = \n\ \ \ \ \ \ \ \
symbols\ /. \n\ \ \ \ \ \ \ \ \ Outer[
List, \n\ \ \ \ \ \ \ \ \ \ \ Partition[
Thread[subvar\ ->
ToString\ /@ sub], \n\ \ \ \ \ \ \ \ \ \ \ \ \ 1], \ {X\ ->
ToString[X]}]; \n\ \ \ \ \ ReleaseHold[
heldsymbols]; \[IndentingNewLine]Remove @@ \((\(\(SymbolName[#1] <>
SymbolName[#2] <> SymbolName[#3] <> SymbolName[#4] <>
SymbolName[#5] &\) @@ # &\) /@
Flatten[Outer[
List, {X}, {\[UnderBracket]}, {Subscript}, {\[UnderBracket]},
sub], 4])\)\[IndentingNewLine]]\)
Comments suggestions and improvements are welcome.
--
Richard Gass
Department of Physics
University of Cincinnati
Cincinnati, OH 45221
phone- 513-556-0519
E-Mail gass at physics.uc.edu