RE: Q: Extract Elements from a List?
- To: mathgroup at smc.vnet.net
- Subject: [mg28982] RE: [mg28968] Q: Extract Elements from a List?
- From: "Higinio Ramos" <higra at gugu.usal.es>
- Date: Thu, 24 May 2001 04:06:59 -0400 (EDT)
- References: <200105230554.BAA01361@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
----- Original Message ----- From: Robert Schuerhuber <robert.schuerhuber at gmx.at> To: mathgroup at smc.vnet.net Subject: [mg28982] [mg28968] Q: Extract Elements from a List? > hi! > > probably a very easy question, but i couldn't find an answer in the > mathematica-book: > > i need to extract elements from a list, starting th element number x and > than taking every yth element, eg: > > with > > list={a,b,c,d,e,f,g,h,i,j} > start=3; > step=2: > > i'd like to get the list > > {c,e,g,i}. > > how can i do this in the easiest way? > > regards, robert This may be done with Take: takeList[list_, n_, s_] := Take[list, {n, Length[list], s}] In[22]:= takeList[list, 3, 2] Out[22]= {c, e, g, i} Higinio
- References:
- Q: Extract Elements from a List?
- From: Robert Schuerhuber <robert.schuerhuber@gmx.at>
- Q: Extract Elements from a List?