Re: Possible bug in Table and/or lists (Mathematica v.7)
- To: mathgroup at smc.vnet.net
- Subject: [mg108129] Re: Possible bug in Table and/or lists (Mathematica v.7)
- From: dh <dh at metrohm.com>
- Date: Tue, 9 Mar 2010 06:19:57 -0500 (EST)
- References: <hmvqbb$1as$1@smc.vnet.net>
Hi Vijay, this has to do with list assignment. If on both side of "=" we have list of the same length, the assignment is element by element. If the length differ, the right list is assigned to every element on the left side. A workaround is to use "Sequence"E.g. try: t[[{1, 2, 3}]] = {q, q, q}; t[[{1, 2, 3}]] = Sequence@{q, q, q}; Daniel On 07.03.2010 10:06, Vijay Kaul wrote: > I found this potential bug in Mathematica 7, running on Win XP and OS > X and it's easily reproducible. > > If I try the following: > > dim = 3; > t = Table[1, {2*dim}, {2*dim}]; > t // Grid > t[[-dim ;;]] = Table[1, {dim}]; > t // Grid > > I get unexpected results: the last three rows, rather than being each > a three element list, are, instead, single "1"s. On the other hand > > dim = 3; > t = Table[1, {2*dim}, {2*dim}]; > t // Grid > t[[-dim ;;]] = Table[1, {dim + 1}]; > t // Grid > > works as expected. > > In general, dimensions where the shorter lists are *not* half the > larger dimension seem to work just fine. I can also reproduce the > problem by creating a list of length 2N and then trying to fill half > of it with lists of length 2N and half with lists of length N. > > Maybe I'm missing something, but it baffled me and some others who > looked at it. > > Also, I'm not sure where or how to find a Mathematica bug-list, and I > didn't see a FAQ around here, but I'm relatively unexposed to usenet, > newsgroups, and Google groups, so I may have missed some obvious > stuff. > > So, with thanks and/or apologies in advance, > -Vijay > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail:<mailto:dh at metrohm.com> Internet:<http://www.metrohm.com>