MathGroup Archive 2004

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

Search the Archive

Re: Notation Question

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

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]}, 
       i_], f_] := MakeExpression[
      RowBox[{ToString[a], "[", i, "]"}]]; 
    MakeBoxes[a[i_], f_] := SubscriptBox[
      MakeBoxes[a, f], MakeBoxes[i, f]]]
x /@ Range[10]

(output suppressed)


scohen at (Sebastian Cohen S) wrote in message news:<c5lfds$bqh$1 at>...
> 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