Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2001

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

Search the Archive

Re: Replacing Parts of a List

  • To: mathgroup at smc.vnet.net
  • Subject: [mg28782] Re: [mg28742] Replacing Parts of a List
  • From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
  • Date: Sat, 12 May 2001 20:18:14 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Sorry, I replied to the message too quickly without looking at my output and
got thoroughly confused (because I was all the time misunderstanding your
question). So my last message was all nonsense. What I meant was something
like this:

In[35]:=
l=Subscript[a,{1,2,3}]
Out[35]=
a
 {1, 2, 3}

In[39]:=
l[[2,3]]=4;

In[38]:=
l

Out[38]=
a
 {1, 2, 4}

In other words, you can change the subscripts in the same way as you change
lists.

Only later I  understood that you are trying to use Sunscript[a,b] as a
variable, and you want to change its values. The natural way to do so is to
use the Notation package. Just copy everything below the dotted line below,
paste into a new notebook and evaluate everything. It should be obvious what
is going on.

-- 
Andrzej Kozlowski
Toyama International University
JAPAN

http://platon.c.u-tokyo.ac.jp/andrzej/
http://sigma.tuins.ac.jp/~andrzej/

on 01.5.12 0:45 PM, Andrzej Kozlowski at andrzej at tuins.ac.jp wrote:

> As I tried to point out the first time, you can do:
> 
> In[1]:=
> l=Subscript[x,y]={1,2,3}
> 
> Out[1]=
> {1,2,3}
> 
> In[2]:=
> l[[3]]=10
> 
> Out[2]=
> 10
> 
> In[3]:=
> Subscript[x,y]
> 
> Out[3]=
> {1,2,3}
> 
> I think this is really not that much more inconvenient than what you
> originally tried to do, is it?
> 
> -- 
> Andrzej Kozlowski
> Toyama International University
> JAPAN
> 
> http://platon.c.u-tokyo.ac.jp/andrzej/
> http://sigma.tuins.ac.jp/~andrzej/
> 
> 
> on 01.5.12 10:40 AM, Jones, Roger M. at rmj at SLAC.Stanford.EDU wrote:
> 
>> To clarify
>> 
>> In[1]:=Subscript[x, y] = {1, 2, 3}
>> 
>> Out1]={1, 2, 3}
>> 
>> To replace the third element I must use :
>> 
>> In[2]:=Subscript[x, y] = ReplacePart[Subscript[x, y], 10, 3]
>> 
>> Out[2]={1, 2,10}
>> 
>> So that now Subscript[x, y] gives:
>> 
>> In[3]:=Subscript[x, y]
>> 
>> Out[3]={1, 2, 10}
>> 
>> 
>> This is unwieldy and I was hoping for a little more condensed notation.
>> However,
>> when using subscripts this appears appears to be the simplest notation
>> available.
>> 
>> -Roger Jones
>> 
>> 
> 


------------------------------------------------------------------
Notebook[{
Cell[BoxData[
    \(<< Utilities`Notation`\)], "Input"],

Cell[BoxData[
    RowBox[{"Symbolize", "[",
      TagBox[\(a\_b\),
        NotationBoxTag,
        TagStyle->"NotationTemplateStyle"], "]"}]], "Input"],

Cell[CellGroupData[{

Cell[BoxData[
    \(a\_b = {1, 2, 3}\)], "Input"],

Cell[BoxData[
    \({1, 2, 3}\)], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
    \(a\_b[\([3]\)] = 10\)], "Input"],

Cell[BoxData[
    \(10\)], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
    \(a\_b\)], "Input"],

Cell[BoxData[
    \({1, 2, 10}\)], "Output"]
}, Open  ]]
}
]



  • Prev by Date: RE: i don't want intersection
  • Next by Date: Re: i don't want intersection
  • Previous by thread: Re: Replacing Parts of a List
  • Next by thread: RE: Re: Replacing Parts of a List