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.