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>
• 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
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

```

• Prev by Date: Re: A NewBie Question
• Next by Date: Re: compile / optimize
• Previous by thread: Re: A NewBie Question
• Next by thread: Re: A NewBie Question