MathGroup Archive 2009

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

Search the Archive

Re: part assigned sequence behavior puzzling

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105302] Re: part assigned sequence behavior puzzling
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Fri, 27 Nov 2009 06:28:01 -0500 (EST)
  • References: <hekujm$96g$1@smc.vnet.net>

I'd say that this is not a wise design decision. IMHO, a statement
like tmp=tmp should have no effect on tmp, whereas with this
SequenceHold situation it has.

Cheers -- Sjoerd

On Nov 26, 6:01 am, Bob Hanlon <hanl... at cox.net> wrote:
> As stated in the documentation for sequence: assignment and replacement f=
unctions have attribute SequenceHold
>
> Attributes[Set]
>
> {HoldFirst,Protected,SequenceHold}
>
> tmp = Range[15]
> tmp[[7]] = Sequence @@ Range[2];
> tmp[[7]] = Sequence @@ Range[2];
> tmp[[7]] = Sequence @@ Range[2];
> tmp
>
> {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}
>
> {1,2,3,4,5,6,1,2,8,9,10,11,12,13,14,15}
>
> tmp = Range[15]
> tmp[[7]] = Sequence @@ Range[2];
> tmp = tmp;
> tmp[[7]] = Sequence @@ Range[2];
> tmp = tmp;
> tmp[[7]] = Sequence @@ Range[2];
> tmp
>
> {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}
>
> {1,2,3,4,5,6,1,2,2,2,8,9,10,11,12,13,14,15}
>
> Bob Hanlon
>
> ---- mkr <mileskra... at gmail.com> wrote:
>
> =============
> I am puzzled by the following behavior:
>
> tmp = Range[15]
> tmp[[7]] = Sequence @@ Range[2];
> tmp[[7]] = Sequence @@ Range[2];
> tmp[[7]] = Sequence @@ Range[2];
> tmp
>
> yields
>
> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
> {1, 2, 3, 4, 5, 6, 1, 2, 8, 9, 10, 11, 12, 13, 14, 15}
>
> I would have expected the repeated assignment to have a repeated
> effect, thus obtaining
>
> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
> {1, 2, 3, 4, 5, 6, 1, 2, 2, 2, 8, 9, 10, 11, 12, 13, 14, 15}
>
> Where/why am I wrong?



  • Prev by Date: Re: Re: simple question
  • Next by Date: ItemSize and ImageSize->Full , I do not understand what happens
  • Previous by thread: Re: part assigned sequence behavior puzzling
  • Next by thread: Re: Re: part assigned sequence behavior puzzling