MathGroup Archive 2003

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

Search the Archive

Re: Part assignment

  • To: mathgroup at smc.vnet.net
  • Subject: [mg44989] Re: [mg44972] Part assignment
  • From: "Sseziwa Mukasa,,(978) 536-2359" <mukasa at jeol.com>
  • Date: Fri, 12 Dec 2003 04:41:28 -0500 (EST)
  • References: <200312111028.FAA13125@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On Dec 11, 2003, at 5:28 AM, Maxim wrote:

> Consider
>
> In[1]:=
> Module[
>   {L={0,0}},
>   L[[1]]=Sequence[1,1];
>   L[[2]]=2;
>   L[[2]]
> ]
>
> Out[1]=
> 1
>
> The first part assignment constructs a list {Sequence[1,1],0}. Then an
> interesting thing happens: part extraction functions (Part and others)
> think that the second element of this list is 1, while part assignment
> (Set) decides that the second element is 0.
>

This is pretty puzzling but I think the explanation is as follows:

- The first assignment does not evaluate L since Set has the attribute 
HoldFirst, thus resulting in {Sequence[1,1},0].  You can never actually 
confirm this because any attempt to display L will evaluate it 
resulting in {1,1,0}.  The second assignment also does not evaluate L, 
resulting in {Sequence[1,1],2}.  Again this can't be confirmed, any 
attempt to display the value of L evaluates it resulting in {1,1,2} 
being displayed.  The final line though does evaluate L, resulting in 
{1,1,2} then takes the second part which is 1.

Regards,

Ssezi


  • Prev by Date: Re: Maybe it's me but the integrator at wolfram doesn't work very well
  • Next by Date: Re: Part assignment
  • Previous by thread: Part assignment
  • Next by thread: Re: Part assignment