MathGroup Archive 2006

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

Search the Archive

Re: Re: bug in Partition?


On 16 Apr 2006, at 14:44, Carl K. Woll wrote:

> Chris Chiasson wrote:
>> Partition[Range[11], 3, 3, {1, 1}, Hold[]]
>>
>> the output is
>>
>> {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11}}
>>
>> I would expect
>>
>> {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, Hold[]}}
>>
>> Might this be because of a ReleaseHold somewhere in the  
>> implementation
>> of Partition?
>>
>> (Ver 5.2, Windows)
>
> Actually, the fifth argument should be a symbol or a list of stuff.
>
> Basically, the symbol case is converted to list form:
>
> Partition[_,_,_,_,symbol]
>
> is converted to
>
> Partition[_,_,_,_,{symbol}]
>
> It turns out that some additional generality was incorporated so that
> the head of the 5th argument doesn't need to be List. So, your  
> sample input
>
> Partition[Range[11], 3, 3, {1, 1}, Hold[]]
>
> was actually interpreted as
>
> Partition[Range[11], 3, 3, {1, 1}, {}
>
> and no padding was done.

This is not quite true. Actually padding was done, but using Sequence 
[], with the effect that it looks as if "no padding was done", see:

Partition[Range[11], 3, 3, {1, 1}, {}]//Trace

Looking at this (in the case of the original example with Hold[])  
made me believe that ReleaseHold was used, although, now I think that  
if were the case it an explicit ReleaseHold would be visible in Trace.
Anyway, now we know the truth and the only question remains: why  
would anyone at WRI make thigs work in this way and not let anyone  
know about it?

Andrzej Kozlowski

Tokyo, Japan


> To get your desired input, use
>
> Partition[Range[11], 3, 3, {1, 1}, {Hold[]}]
>
> Note that because the head is immaterial, the following input will
> generate the same output:
>
> Partition[Range[11], 3, 3, {1, 1}, foo[Hold[]]]
>
> Carl Woll
> Wolfram Research
>


  • Prev by Date: calculating contradicts plotting
  • Next by Date: List programming, speed improvement
  • Previous by thread: Re: bug in Partition?
  • Next by thread: Re: Re: bug in Partition?