Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Re: Bug with Sequence

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104656] Re: [mg104633] Re: Bug with Sequence
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Fri, 6 Nov 2009 05:15:12 -0500 (EST)
  • References: <hcr7ac$8di$1@smc.vnet.net> <200911050851.DAA21614@smc.vnet.net>
  • Reply-to: drmajorbob at yahoo.com

On the other hand, "forcing the evaluation" of x below does nothing:

x = Sequence[]
x = x

Sequence[]

Sequence[]

and yet:

x = Sequence[]
x = {x}

Sequence[]

{}

Bobby

On Thu, 05 Nov 2009 02:51:19 -0600, Szabolcs Horvát <szhorvat at gmail.com>  
wrote:

> On 2009.11.04. 7:34, dh wrote:
>> Hello,
>>
>> has anybody an explanation for the behavior of "Sequence"? I think it is
>>
>> an ugly bug.
>>
>> Consider the following that shoud succesively shorten the list t:
>>
>>
>>
>> t = {1, 2, 3}; j = 0;
>>
>> While[ ++j<  4, t[[1]] = Sequence[]; Print[t]]
>>
>>
>>
>> this returns: {2,3} three times.Dropping of the first element only seems
>>
>> to work once.
>>
>> If you say Information[t] you get:
>>
>> t={Sequence[],2,3}
>>
>
> Hi Daniel,
>
> What seems to be happening when
>
> t[[1]] = x
>
> is evaluated is that first x is evaluated, then the first element of t
> is changed to (the result of the evaluation of) x.  But t itself does
> not go through an evaluation process.  Thus an assignment like t[[1]] is
> only capable of changing the first element of t but nothing else.
>
> If we force t to be evaluated in its entirety after every assignment,
> then the program will work as expected:
>
> While[ ++j < 4, t[[1]] = Sequence[]; t = t; Print[t]]
>
> The fact that t[[1]] = x type assignments are not able to affect
> anything else than the first element is not necessarily a bad thing.
> Consider the following (admittedly unusual) example:
>
> u = Unevaluated[{RandomInteger[], RandomInteger[]}]
>
> If u[[1]] = 2 would trigger an evaluation of the entire contents of u,
> the second element would change too.  However, I wouldn't expect that to
> happen in this particular example.
>
> I hope this helps,
> Szabolcs
>


-- 
DrMajorBob at yahoo.com


  • Prev by Date: Re: Aligning framed graphics in rows
  • Next by Date: Re: ForAll testing equality, and Limit evaluating wrong
  • Previous by thread: Re: Bug with Sequence
  • Next by thread: Problem with mouse EventHandler on linux