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?