MathGroup Archive 2004

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

Search the Archive

Re: Notation Question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg47579] Re: Notation Question
  • From: drbob at bigfoot.com (Bobby R. Treat)
  • Date: Fri, 16 Apr 2004 05:21:20 -0400 (EDT)
  • References: <c5lfds$bqh$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

After evaluating subFunction[x], you can input x[i] or x subscripted
by i interchangeably, and always display the subscripted form. I like
it much better than the Part solution; maybe you will too. Part has a
nasty habit of complaining when i isn't an integer, or it's too big,
too small, etc., and functions are just a lot more flexible.

subFunction[a_Symbol] := 
  Block[{aa = ToString[a]}, 
   MakeExpression[SubscriptBox[ToString[a], 
       i_], f_] := MakeExpression[
      RowBox[{ToString[a], "[", i, "]"}]]; 
    MakeBoxes[a[i_], f_] := SubscriptBox[
      MakeBoxes[a, f], MakeBoxes[i, f]]]
Clear[x]
subFunction[x]
x /@ Range[10]

(output suppressed)

Bobby

scohen at cable.net.co (Sebastian Cohen S) wrote in message news:<c5lfds$bqh$1 at smc.vnet.net>...
> Hi everyone,
> 
> I need to make Mathematica understand that:
> 
> Subscript[X,j] for j = 3
> 
> for example is Part[X,3] and more generally to understand that:
> 
> the input should internally handle Subscript[exp, i,j] 
> as Part[exp, i,j]
> 
> Anyone got any ideas?
> 
> Thanks in advance,
> 
> Sebastian Cohen S


  • Prev by Date: RE: Contour lines with individual labels
  • Next by Date: Re: Saving as HTML -- Page width problems
  • Previous by thread: Re: Notation Question
  • Next by thread: Obtaining Standard Errors when using FindMinimum in Mathematica