Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Q: Extract Elements from a List?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg28981] Re: [mg28968] Q: Extract Elements from a List?
  • From: Ken Levasseur <Kenneth_Levasseur at uml.edu>
  • Date: Thu, 24 May 2001 04:06:58 -0400 (EDT)
  • References: <200105230554.BAA01361@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Robert:

One way to do it is     Map[list[[#]] &, Range[x, Length[list], y]], but
even simpler is
list[[ Range[x, Length[list], y]]].


In[7]:=
Map[list[[#]] &, Range[3, Length[list], 2]]

Out[7]=
\!\(TraditionalForm\`{c, e, g, i}\)

In[8]:=
list[[ Range[3, Length[list], 2]]]

Out[8]=
\!\(TraditionalForm\`{c, e, g, i}\)

Ken Levasseur
UMass Lowell

Robert Schuerhuber wrote:

> 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



  • Prev by Date: A tricky equation
  • Next by Date: Re: Extract Elements from a List?
  • Previous by thread: RE: Q: Extract Elements from a List?
  • Next by thread: Re: Q: Extract Elements from a List?