MathGroup Archive 2010

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

Search the Archive

Re: Possible bug in Table and/or lists (Mathematica v.7)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg108091] Re: Possible bug in Table and/or lists (Mathematica v.7)
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Mon, 8 Mar 2010 06:13:05 -0500 (EST)
  • References: <hmvqbb$1as$1@smc.vnet.net>

If you examine the examples in the Span (;;) help page you see that
this behaviour is in there.

The rule apparently is that if the number of elements in the span on
the LHS equals the number of elements on the RHS then elements are set
one-by-one. If the numbers don't match then the whole RHS is used to
set each member of the LHS.

I can see both advantages and disadvantages of this behaviour. For
one, it is easy to copy in a large range of values and it's similar to
saying
{var1,var2,var3} = {6,3,5}.

On the other hand, it doesn't seem to be possible to assign each
member of the LHS with a list of length equal to the number of
elements on the LHS. If you want to set the elements to list with
unknown length it seems you have to take care of the exception where
the list has this special length. Very awkward and sure to lead to
errors.

Cheers -- Sjoerd

On Mar 7, 11:06 am, Vijay Kaul <vijayk... at gmail.com> 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



  • Prev by Date: Re: Conjugate of symbolic expressions
  • Next by Date: Re: Help Improving this integral calculation / solution
  • Previous by thread: Re: Possible bug in Table and/or lists (Mathematica v.7)
  • Next by thread: Re: Possible bug in Table and/or lists (Mathematica v.7)