Re: part assigned sequence behavior puzzling
- To: mathgroup at smc.vnet.net
- Subject: [mg105275] Re: [mg105228] part assigned sequence behavior puzzling
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Wed, 25 Nov 2009 23:02:03 -0500 (EST)
- Reply-to: hanlonr at cox.net
As stated in the documentation for sequence: assignment and replacement functions 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 <mileskrains 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?