Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7402

Re: Span Set nasty bug

From Oliver Ruebenkoenig <ruebenko@wolfram.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Span Set nasty bug
Date 2011-12-22 09:26 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jcut4k$dgi$1@smc.vnet.net> (permalink)
References <201112161054.FAA07002@smc.vnet.net>

Show all headers | View raw



On Fri, 16 Dec 2011, roby wrote:

> Dear group & Mathematica team
>
> I am trying to assign a non existing element member of a 2D List.
> Due to the coosen Span the element should not exist respectivly not be
> assigned.
> when the non existing element is queried e.g. {} should be returned
>
> please take a look on the following assignment:
>
> In[43]:= t = Table[0, {15}, {15}];
> t[[1 ;; 0, 1 ;; 1]] = 1;
> t[[1 ;; 0, 1 ;; 1]]
> t[[1, 1]]
>
> Out[45]= {}
>
> Out[46]= 0
>
> so far so good no element gets assigned and the query works,
> after changing 15 to 16 or greater the query still works but  the
> following happens element [[1,1]] gets a value assigned:
>
> In[47]:= t = Table[0, {16}, {16}];
> t[[1 ;; 0, 1 ;; 1]] = 1;
> t[[1 ;; 0, 1 ;; 1]]
> t[[1, 1]]
>
> Out[49]= {}
>
> Out[50]= 1
>
> Is this a bug or is it a feature ?
>
>

Roby, are you aware that expr[[0]] gives access to the head? Why do you do 
it this way?

The fact that results differ is due to the compilation in Table. You can 
modify this behavior (which I do not suggest)

SetSystemOptions["CompileOptions" -> {"TableCompileLength" -> 1}]

I think if you do not want to assign, do not do it.

t[[1]]
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

t[[0]]
List

t[[1 ;; 0]]
{}

Length[t[[1 ;; 0]]]
0

(* it is somewhat unfortunate that the following does not issue a 
message *)
t[[1 ;; 0, 1]]
{}

t[[1 ;; 0]][[1]]

Oliver

Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: Span Set nasty bug Oliver Ruebenkoenig <ruebenko@wolfram.com> - 2011-12-22 09:26 +0000
  Re: Span Set nasty bug roby <roby.nowak@gmail.com> - 2011-12-23 12:15 +0000

csiph-web