Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

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: [mg47480] Re: Partitioning a list into unequal partitions
  • From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig-de>
  • Date: Wed, 14 Apr 2004 07:16:28 -0400 (EDT)
  • Organization: Uni Leipzig
  • References: <c5gfdp$an0$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

nsplit[{}, _] := {}
nsplit[l_List, n_Integer] := Join[{Take[l, n]}, nsplit[Drop[l, n], n + 1]]

and



n = 4;
data = Table[i, {i, 1, n*(n + 1)/2}];

nsplit[data, 1]



Regards

 Jens

"DIAMOND Mark R." <dot at dot.dot> schrieb im Newsbeitrag
news:c5gfdp$an0$1 at smc.vnet.net...
> 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.
>
> Cheers
>
> Mark R. Diamond
>
>
>
>



  • Prev by Date: Re: Partitioning a list into unequal partitions
  • Next by Date: RE: Format Style
  • Previous by thread: Re: Partitioning a list into unequal partitions
  • Next by thread: Re: Partitioning a list into unequal partitions