Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1997
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1997

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

Search the Archive

Re: a[[2]][[3]] = 1 error? why?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg8930] Re: [mg8874] a[[2]][[3]] = 1 error? why?
  • From: David Withoff <withoff>
  • Date: Sat, 4 Oct 1997 22:08:08 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

> a=Table[i*j,{i,1,3},{j,1,3}];
> a[[2]][[3]]
>
> answer : 6 (as it should be)
> so why assignment to
> a[[2]][[3]] = 3
> doesn't work?

This could presumably be made to work, but Part assignments are a
rather special type of assignment, and in current versions of
Mathematica have only been made to work for a single level of Part,
not for nested Part.  a[[2]][[3]] is Part[Part[a, 2], 3].  You
can make an assignment to the [[2,3]] element of this array
using a[[2,3]] instead, as in

In[1]:= a=Table[i*j,{i,1,3},{j,1,3}];

In[2]:= a[[2,3]] = 3

Out[2]= 3

In[3]:= a

Out[3]= {{1, 2, 3}, {2, 4, 3}, {3, 6, 9}}

Dave Withoff
Wolfram Research


  • Prev by Date: LabVIEW front end
  • Next by Date: Re: Order of execution of initialization cells
  • Previous by thread: Re: a[[2]][[3]] = 1 error? why?
  • Next by thread: Unsolved integral