MathGroup Archive 2003

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

Search the Archive

Re: Part assignment

  • To: mathgroup at smc.vnet.net
  • Subject: [mg45167] Re: Part assignment
  • From: Maxim <dontsendhere@.>
  • Date: Fri, 19 Dec 2003 06:57:33 -0500 (EST)
  • References: <brmqdq$obf$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com


"Wolf, Hartmut" wrote:

> >-----Original Message-----
> >From: Maxim [mailto:dontsendhere@.]
To: mathgroup at smc.vnet.net
> >Sent: Sunday, December 14, 2003 12:23 PM
> >To: mathgroup at smc.vnet.net
> >Subject: [mg45167]  Re: Part assignment
> >
> >
> >
> >
> >Second assignment: L[[2]]=2, or Set[Part[L,2],2]. Here L is
> >not evaluated
> >(because assigment treats Part in a special way -- if there
> >were another
> >non-holding function instead of Part, L would be evaluated),
> >so there's simply
> >no Sequence objects here and SequenceHold can't have any effect.
> >
>
> We certainly agree that after the second assignment L[[1]]= Sequence[1,1]
> has the value {Sequence[1,1], 0}, (it would have the same value after the
> assignment Set[L[[1]],1,1], but that is, as shown, a different story). Now
> why does L[[2]] = 2, overwrite that 0, and not the second 1 from
> Sequence[1,1]?  This simply is because of the HoldFirst property of Set
> (such L ist *not* evaluated, does *not* result to {1, 1, 0}[[2]] at lhs, and
> as a special form behaves "like an Upvalue for Part" just redefining the
> second slot, and leaving everthing else untouched (of course, we might say),
> hence the result.
>

One correction: L in Set[Part[L,2],2] is left unevaluated *not* just because of
the HoldFirst attribute of Set. Documentation for Set says: "If lhs is of the
form f[args], then args are evaluated". So Part is an exception from an
exception.

Maxim Rytin
m.r at prontomail.com



  • Prev by Date: Re: arXiv style sheet on Mac OSX
  • Next by Date: Re: Wierdness with the laplacian
  • Previous by thread: RE: Re: Part assignment
  • Next by thread: how to change arguments of standard functions ?