MathGroup Archive 2004

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

Search the Archive

Re: Partitioning a list into unequal partitions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg47476] Re: Partitioning a list into unequal partitions
  • From: bobhanlon at aol.com (Bob Hanlon)
  • Date: Wed, 14 Apr 2004 07:16:25 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

x=Range[11];

k=0;
Rest[NestList[
    (k++;Take[x,{k(k-1)/2+1,k(k+1)/2}])&, 
    x,Floor[(Sqrt[1+8Length[x]]-1)/2]]]

{{1}, {2, 3}, {4, 5, 6}, {7, 8, 9, 10}}


Bob Hanlon

In article <c5gfdp$an0$1 at smc.vnet.net>, "DIAMOND Mark R." <dot at dot.dot> wrote:

<< Could someone please show me a simple (non-procedural) way of partitioning a
list into 1,2,3 ... n disjoint sublists, where the length of the list is
guaranteed to be correct (i.e. n*(n+1)/2)

I can't see a way, and yet I'm sure there *must* be a one-liner using Fold.


  • Prev by Date: DSOLVE in 5.01 ??
  • Next by Date: RE: Re: Is there any productive way to use Mathematica + pdfLaTeX?
  • Previous by thread: Re: Partitioning a list into unequal partitions (Thanks)
  • Next by thread: Re: Partitioning a list into unequal partitions