MathGroup Archive 2012

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

Search the Archive

Re: Modifying an entry in array specified by a list of arbitrary length

  • To: mathgroup at smc.vnet.net
  • Subject: [mg127169] Re: Modifying an entry in array specified by a list of arbitrary length
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Thu, 5 Jul 2012 06:10:32 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

On 7/4/12 at 3:32 AM, samid.hoda at gmail.com wrote:

>I want to edit an element whose position is specified by an
>arbitrary list that is a result of a computation (the list is not of
>fixed length). Something like

>i = {1,2,3} Extract[X,i]+=1

>except that Extract passes X by value instead of by reference.
>Anyone have any ideas?

In[1]:= data = RandomReal[1, 5];
data + SparseArray[{2 -> 1}, Length@data]

Out[2]= {0.792931,1.11432,0.235235,0.730301,0.48574}




  • Prev by Date: Re: Rearranging terms - user-defined
  • Next by Date: Re: How to rectify the error for NDSolve ?
  • Previous by thread: Modifying an entry in array specified by a list of arbitrary length
  • Next by thread: Re: Modifying an entry in array specified by a list of arbitrary length