Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Extracting elements with odd indices' topicStudent Support Forum > General > "Extracting elements with odd indices"

Next Comment >Help | Reply To Topic
Author Comment/Response
Ben Kovitz
11/21/04 12:56pm

Is there an easy, elegant way to extract all the elements of a list with an odd index?

I came up with this:

oddElements = Table[data[[i]], {i, 1, Length[data], 2}]

which works, but it seems like there ought to be a way that uses OddQ on the index, something like this:

oddElements = Select[data, OddQ[somehow get the index of the element]& ]

Is there a way?

Ben Kovitz

URL: ,

Subject (listing for 'Extracting elements with odd indices')
Author Date Posted
Extracting elements with odd indices Ben Kovitz 11/21/04 12:56pm
Re: Extracting elements with odd indices Henry Lamb 11/21/04 11:58pm
Re: Extracting elements with odd indices highegg 11/22/04 11:38am
Re: Extracting elements with odd indices Ben Kovitz 12/11/04 2:34pm
Next Comment >Help | Reply To Topic