x = Array[a, {4, 3, 5}];
i = {1, 2, 3};
Element to be modified
x[[Sequence @@ i]]
a[1, 2, 3]
Change element
x[[Sequence @@ i]] += 1
1 + a[1, 2, 3]
Verifying that array was modified
x[[Sequence @@ i]]
1 + a[1, 2, 3]
Bob Hanlon
On Wed, Jul 4, 2012 at 3:32 AM, <samid.hoda@gmail.com> wrote:
> Hi,
>
> 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?
>
> Thanks,
> Sam
>
|
|
0
|
|
|
|
Reply
|
hanlonr357 (720)
|
7/5/2012 10:17:56 AM |
|