Re: visual subscripts with assignment
- To: mathgroup@smc.vnet.net
- Subject: [mg11069] Re: [mg11026] visual subscripts with assignment
- From: jpk@max.mpae.gwdg.de
- Date: Wed, 18 Feb 1998 20:32:21 -0500
Hi,
this will work for assigments.
Unprotect[Set]
Set[Subscript[x,i_],val_]:=x[[i]]=val Protect[Set]
Hope that helps
Jens
> Hi Jen,
>
> I tried your suggestion and got the same result. Did it work
> for you?
>
> Issac
>
> -----Original Message-----
> From: jpk@max.mpae.gwdg.de <jpk@max.mpae.gwdg.de>
To: mathgroup@smc.vnet.net
> To: ijtrotts@ucdavis.edu <ijtrotts@ucdavis.edu>
> Cc: mathgroup@smc.vnet.net <mathgroup@smc.vnet.net>
> Date: Tuesday, February 17, 1998 1:35 AM
> Subject: [mg11069] Re: [mg11026] visual subscripts with assignment
>
>
> >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
> >>
> >>
> >>
> >
>