MathGroup Archive 2009

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

Search the Archive

Re: Re: RandomReal gets stuck

  • To: mathgroup at
  • Subject: [mg100728] Re: [mg100687] Re: RandomReal gets stuck
  • From: DrMajorBob <btreat1 at>
  • Date: Thu, 11 Jun 2009 21:44:45 -0400 (EDT)
  • Organization: Deep Space Corps of Engineers
  • References: <> <h0fvjl$rb1$>
  • Reply-to: drmajorbob at

You're correct that Block and aa=ToString@a are unnecessary; it's a very  
long time since I looked at the code.

But it works just fine, as it is or with those removed; I just neglected  
to tell you how to use it.

For instance,

   a_Symbol] := (MakeExpression[SubscriptBox[ToString@a, i_], f_] :=
    MakeExpression[RowBox[{ToString@a, "[", i, "]"}]];
   MakeBoxes[a[i_], f_] :=
    SubscriptBox[MakeBoxes[a, f], MakeBoxes[i, f]])

Now enter



Array[a, 10]
Array[Subscript[a, #] &, 10]

and observe. Both outputs are the same.

Or enter


whose output is


(But looking like a subscripted variable, of course.)

It only affects the symbol a, which you've set up using subFunction[a].


On Thu, 11 Jun 2009 06:07:36 -0500, Alexey <lehin.p at> wrote:

> On 7 =C9=C0=CE, 13:00, DrMajorBob <btre... at> wrote:
>> If you want to use subscripted variables, it might help to use this  
>> code:
>> subFunction::usage = "subFunction[a] causes inputting a[i] or \
>> \!\(\*SubscriptBox[\"a\", \"i\"]\) to be synonymous, while always \
>> displaying the latter in outputs."
>> "subFunction[a] causes inputting a[i] or \!\(\*SubscriptBox[\"a\", \
>> \"i\"]\) to be synonymous, while always displaying the latter in \
>> outputs."
>> subFunction[a_Symbol]:=Block[{aa=ToString[a]},MakeExpression[Subscrip=
> tBox[ToString@a,i_],f_]:=MakeExpression[RowBox[{ToString@a,"[",i,"]"}]];MakeBoxes[a[i_],f_]:=SubscriptBox[MakeBoxes[a,f],MakeBoxes[i,f]]]
>> The result is that you can refer to a[i] or Subscript[a,i]
>> interchangeably, but it always displays in the subscripted form. I find  
>> it
>> much easier to use a[i] while typing formulas, so I'm getting the best  
>> of
>> both worlds.
>> Not sure if that addresses everything brought up on the thread, of  
>> course.
>> Bobby
> It is very interesting, thank you. But as I understand the definition
> aa=ToString[a]
> inside Block is not necessary. And Mathematica does not recognizes
> input Subscript[a,i] as equivalent to a[i]. There seems to be some
> errors in the code.

DrMajorBob at

  • Prev by Date: Re: Re: differentiation operator
  • Next by Date: Re: Getting histogram information
  • Previous by thread: Re: Re: RandomReal gets stuck
  • Next by thread: Re: RandomReal gets stuck