Re: A NewBie Question
- To: mathgroup at smc.vnet.net
- Subject: [mg53613] Re: [mg53582] A NewBie Question
- From: DrBob <drbob at bigfoot.com>
- Date: Thu, 20 Jan 2005 03:47:55 -0500 (EST)
- References: <200501190659.BAA06806@smc.vnet.net>
- Reply-to: drbob at bigfoot.com
- Sender: owner-wri-mathgroup at wolfram.com
This may seem tedious as well, of course: Clear[f,g] f[{x___,a_List,b:{n_,c___}}]:={x,Take[a,n],Drop[a,n],{c}} f[x_]:=x g[x_List,y:{__Integer?(#1<=0&)}]:=Drop[FixedPoint[f,{PadRight[x, Plus@@y,x],y},50],-2] g[{a,b,c,d,e,f,g,h,i},{2,3,4}] g[{a,b,c,d,e,f,g,h,i},{2,3,4,0,7}] {{a,b},{c,d,e},{f,g,h,i}} {{a,b},{c,d,e},{f,g,h,i},{},{a,b,c,d,e,f,g}} Bobby On Wed, 19 Jan 2005 01:59:34 -0500 (EST), Zhe Hu <iamhuzhe at gmail.com> wrote: > Is there a way to take parts of a list as follows: > > takeParts[{a,b,c,d,e,f,g,h,i}, {2,3,4}] > > {{a,b}, {c,d,e}, {f,g,h,i}} > > A tedious way might be transforming {2, 3, 4} into {{1,2}, {3,5}, {6, > 9}} (by Fold) and then Part/@ onto it. Is there a simpler way to do > it? > > Thanks, > Hu Zhe > > > > -- DrBob at bigfoot.com www.eclecticdreams.net
- References:
- A NewBie Question
- From: Zhe Hu <iamhuzhe@gmail.com>
- A NewBie Question