MathGroup Archive 2006

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

Search the Archive

Re: bug in Partition?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65693] Re: [mg65679] bug in Partition?
  • From: "Carl K. Woll" <carlw at wolfram.com>
  • Date: Sun, 16 Apr 2006 01:44:49 -0400 (EDT)
  • References: <200604140832.EAA22075@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

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. 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: Re: bug in Partition?
  • Next by Date: Re: List Operations
  • Previous by thread: Re: bug in Partition?
  • Next by thread: Re: Re: bug in Partition?