       Re: List of Matrices

• To: mathgroup at smc.vnet.net
• Subject: [mg15251] Re: List of Matrices
• From: "Allan Hayes" <hay at haystack.demon.co.uk>
• Date: Mon, 28 Dec 1998 02:37:49 -0500
• References: <764t8l\$bjh@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```The entry
exp[[index]]= rhs
works  only if expr is a symbol with immediate value (given by = and not
:=) having a position index.
This behavour is made possible by Set and SetDelayed both holding their
first place and being able to examine it before deciding what to do.
Neither expr nor expr[[index]] are evaluated but the stored value of
expr is altered directly (this be very efficient)

The following works
a= {1};
?a
"Global`a"
a = {1}
a[] =2;
?a
"Global`a"
a = {2}
If a[] were were evaluatad in the process then we would have got 1
=2, which would not be  accepted.

The following are examples of failure.

a[] =3;
Set::"partw": "Part \!\(2\) of \!\({2}\) does not exist."

and

a[[1,2]]=3;
Set::"partd":
"Part specification \!\(a \\[LeftDoubleBracket] \(1, 2\) \
\\[RightDoubleBracket]\) is longer than depth of object."

b:={1};

b[] =3;
Set::"noval":
"Symbol \!\(b\) in part assignment does not have an immediate value."

c={1};

c[]=3;
Set::"noval":
"Symbol \!\(c\) in part assignment does not have an immediate value."

Here is an extra check that expr[[index]] is not evaluated. d =
{Unevaluated[x=4]};

?d
"Global`d"
d = {Unevaluated[x = 4]}
d[]= 3;

d has been changed

?d
"Global`d"
d = {3}

But x = 4 has not been evaluated
x
x

Peter wrote in message <764t8l\$bjh at smc.vnet.net>...
>I have the following sequence of commands:
>
>In:=
>s=IdentityMatrix
>
>Out=
>{{1,0},{0,1}}
>
>In:=
>ss=s
>
>Out=
>{{1,0},{0,1}}
>
>In:=
>ss[[1,1]]
>
>Out=
>1
>
>In:=
>ss[[1,1]]=3
>
>Set::setps: ss in assignment of part is not a symbol."
>
>Out=
>3
>
>Why can I read the entry ss[[1,1]] but can not change its value ?
>What do I have to do to change this value ?
>
>Thank's (once more) for any help
>
>                                                    pedro
>
>
>

```

• Prev by Date: Re: Matrix Problem
• Next by Date: Re: Reading Mathematica 3.0 notebooks in Mathematica 2.2
• Previous by thread: List of Matrices