Re: Partition
- To: mathgroup at smc.vnet.net
- Subject: [mg71669] Re: Partition
- From: Bill Rowe <readnewsciv at sbcglobal.net>
- Date: Sun, 26 Nov 2006 03:48:53 -0500 (EST)
On 11/25/06 at 5:36 AM, hussain.alqahtani at gmail.com (KFUPM) wrote:
>I have a very large list of numbers that look like this: ( although
>the size is different)
>list={a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}
>And i need to rewrite the list into
>list2={a,{b,c,d,e},f,{g,h,i,j,},k,{l,m,n,o}}
>Since my list is too big, i need Mathematica to do it for me
>regardless of the site of the list.
Here is one solution
In[5]:=
Flatten[{First@#,Rest@#}&/@Partition[list,5],1]
Out[5]=
{a,{b,c,d,e},f,{g,h,i,j},k,{l,m,n,o}}
--
To reply via email subtract one hundred and four