Re: visual subscripts with assignment
- To: mathgroup@smc.vnet.net
- Subject: [mg11039] Re: [mg11026] visual subscripts with assignment
- From: jpk@max.mpae.gwdg.de
- Date: Wed, 18 Feb 1998 20:31:38 -0500
Hi Isaac,
the problem is that Subscript evaluate it's argument. When x has a value
assigned Subscript[x,_] will evaluate to the value ({1,2,3,4,5} in Your
example)
Here is the woking definition
SetAttributes[Subscript,HoldFirst]
x/: Subscript[x,i_]:=x[[i]] /; Length[x]>i
h
Hope that helps
Jens
> Can someone tell me why assignment doesn't seem to work with visual
> subscripting? Here's what I got:
>
> In[1]:=
> \!\(x_\_i_ := x[\([i]\)]\)
> In[2]:=
> x={1,2,3,4}
> Out[2]=
> {1,2,3,4}
> In[3]:=
> \!\(x\_2\)
> Out[3]=
> 2
> In[4]:=
> \!\(x\_2 = 5\)
> Out[4]=
> 5
> In[5]:=
> x
> Out[5]=
> {1,2,3,4}
>
> Issac
>
>
>