Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: please explain why ToExpression[SubscriptBox["x","1"],StandardForm] ...

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71852] Re: please explain why ToExpression[SubscriptBox["x","1"],StandardForm] ...
  • From: "Andrew Moylan" <andrew.j.moylan at gmail.com>
  • Date: Fri, 1 Dec 2006 06:21:59 -0500 (EST)
  • References: <ekmdup$8bq$1@smc.vnet.net>

Hi Chris,

I can't immediately see what's wrong with your code. For your interest,
here's the code of my personal SubscriptSymbols` package that I use all
the time to make all subscripts behave like symbols. Unlike the
Utilities`Notation` package, it works just fine in batch mode too,
which is the reason I wrote it:

BeginPackage["SubscriptSymbols`"];

Begin["`Private`"];

SubscriptToProxySymbol[_] = Null;

MakeExpression[SubscriptBox[a_, b_], StandardForm] :=
 Module[{proxy, boxes = SubscriptBox[a, b]},
  proxy = SubscriptToProxySymbol[boxes];
   If[proxy === Null,
    proxy = ToString[Unique[SubscriptSymbolsProxySymbol]];
    SubscriptToProxySymbol[boxes] = proxy;
    With[{n = Symbol[proxy]},
     MakeBoxes[n, StandardForm] :=  boxes];
    ];
    MakeExpression[RowBox[{proxy}
   ]
  ]
 ]

End[];

EndPackage[];

Cheers,
Andrew


On Nov 30, 10:06 pm, "Chris Chiasson" <c... at chiasson.name> wrote:
> fails when the definition
>
> MakeExpression[SubscriptBox["x","1"],___]=dog;
>
> is active.
>
> I think it is related to the output of
>
> BoxForm`TopLevelMakeExpression[StripBoxes[SubscriptBox["x","1"]],StandardForm]
>
> being
>
> ErrorBox[dog].
>
> If you can answer that, then I may be able to make my solution to
> " Using subscripts in function-parameter names" work... here
> is what I have so far:
>
> Unprotect[SubscriptBox];
> With[{usc=FromCharacterCode[63316]},
>     subscriptAsSymbol[symb_Symbol]:=
>       With[{symbStr=ToString@symb},
>         SubscriptBox/:
>           MakeExpression[SubscriptBox[symbStr,scriptStrs__String],format_]:=
>           MakeExpression[SubscriptBox[symbStr,scriptStrs],format]=
>             With[{symbWithSub=
>                   ToExpression[
>                     ToString@
>                       BoxForm`Intercalate[SequenceForm[symbStr,scriptStrs],
>                         usc],format]},
>               MakeBoxes[symbWithSub,_]=SubscriptBox[symbStr,scriptStrs];
>               symbWithSub]]];
> subscriptAsSymbol@x;
> ToExpression[SubscriptBox["x","1"],StandardForm]
> 
> --http://chris.chiasson.name/


  • Prev by Date: Re: Re: Strange empty set of solutions
  • Next by Date: Re: Algorithm used by "Reduce" function
  • Previous by thread: NETLink: LoadNETAssembly["C:\\lego\\Debug\\C4F.LegoRcx.dll"] failed
  • Next by thread: link: http://math.fullerton.edu/mathews/