Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #7402 > unrolled thread
| Started by | Oliver Ruebenkoenig <ruebenko@wolfram.com> |
|---|---|
| First post | 2011-12-22 09:26 +0000 |
| Last post | 2011-12-23 12:15 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
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
| From | Oliver Ruebenkoenig <ruebenko@wolfram.com> |
|---|---|
| Date | 2011-12-22 09:26 +0000 |
| Subject | Re: Span Set nasty bug |
| Message-ID | <jcut4k$dgi$1@smc.vnet.net> |
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
[toc] | [next] | [standalone]
| From | roby <roby.nowak@gmail.com> |
|---|---|
| Date | 2011-12-23 12:15 +0000 |
| Message-ID | <jd1rcq$1ro$1@smc.vnet.net> |
| In reply to | #7402 |
> Roby, are you aware that expr[[0]] gives access to the head? yes, this is clear to me. But if you look carful at my post then you will see that I do not access the element with the array index 0 (the Head). > I think if you do not want to assign, do not do it. again look carful at my post I don't want and I do not assign to element [[1,1]], the assignment just happens by failure! > (* it is somewhat unfortunate that the following does not issue a message *) > t[[1 ;; 0, 1]] ... perhaps right perhaps wrong, depends on the exact definition of Span[ ] wich in turn should depend on what is recognized as suitable. look at my reply to shizu there I have explained a reasonable application. As the Mathematica behavior now is, I of course must prevent empty Span[ ] I would prefer a defined behavoiur similar as e.g. for Range[1,0] which returns an empty List. One of the principles of Mathematica is elegant functional programming which e.g. avoids thigs like loops etc., one of the helpful features in this connection is Span[ ]. As explained I am looking for a construct that assigns a variable number of elements that means even 0, 1 or any other random number provided as a variable. This works perfekt for Matrices < 15x15, pleeeeease, pleeeease fix it for bigger ones. By the way I have reported this to the Wolfram support. The first answer was that the behaviour is "unexpected" and that the issue is forwarded to the developers. As I had the pleasure to meet you at the Mathematica 2011 Conference in Vienna I would not be too much surpised if the isssu would be forwarded to you ;) Cheers Robert
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web