MathGroup Archive 2006

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

Search the Archive

Re: Re: bug in Partition?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65809] Re: [mg65693] Re: [mg65679] bug in Partition?
  • From: "Chris Chiasson" <chris at chiasson.name>
  • Date: Mon, 17 Apr 2006 02:29:05 -0400 (EDT)
  • References: <200604140832.EAA22075@smc.vnet.net> <200604160544.BAA07903@smc.vnet.net> <A8E113F2-1C19-40C6-8E57-8FEBF7EE803D@mimuw.edu.pl>
  • Sender: owner-wri-mathgroup at wolfram.com

I do agree that it feels a little weird to treat non list expressions
in the last argument as holding subexpressions to be sequenced into
the output as needed. Could someone put a note in the documentation of
the next version (har har har) to the effect that, if you want to pad
with something that has arguments (instead of something that is just a
symbol), that you have to put a "wrapper" around it?

On 4/16/06, Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote:
> *This message was transferred with a trial version of CommuniGate(tm) Pro*
>
> 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
> >
>
>


--
http://chris.chiasson.name/


  • Prev by Date: Re: Transfer function animation
  • Next by Date: CPU usage on Solaris - I have posted.
  • Previous by thread: Re: Re: bug in Partition?
  • Next by thread: NDSolve