MathGroup Archive 1998

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

Search the Archive

Re: list assignment problem



jlist = {{1, 2}, {3, 4}}; 

To understand what happens with jlist[[1]][[2]], implement it a step at
a time the way it would be interpretted.

jlist[[1]]

{1, 2}

This is the first row of the matrix.

%[[2]]

2

This is the second element of the two element list.

% = 6

Set::write: Tag Out in % is Protected.

6

That is you asked for it to make the assignment 2 = 6.  This assignment 
couldn't be made and it returned the last meaningful value which it
has, the 6
 from the attempted assignment.

jlist[[1]][[2]] = 6

Set::setps: jlist[[1]] in assignment of part is not a symbol.

6

When this is all done on one line, Mathematica concludes that there is
no  symbol involved in the assignment slightly earlier and gives you a
different  error message.  The 6 does not reflect the result of an
assignment since no assignment can be made.

Bob Hanlon

In a message dated 5/15/98 12:21:26 PM, you wrote:

>I would like to thank everyone who responded to my question.
>I know now how to do it right and it works in my program fine
>but I still dont know really the difference between these two
>stmts:
>
>jlist[[1]][[2]]=6 which is wrong
>and
>jlist[[1,2]]=6 which is right.
>To read the values of index 1 and 2
>both will give 6 but in the assignment
>only the 2nd one works. Is there any
>difference between the two stmts ?



  • Prev by Date: Re: Create Auto Save Package
  • Next by Date: Re: Comparing side by side notebook files
  • Prev by thread: list assignment problem
  • Next by thread: Re: list assignment problem