MathGroup Archive 1998

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

Search the Archive

Re: List Manipulation wrote:
> Hola!
>   Hope you're all doing well.  If I have a list of n lists, and want to
> get rid of all the even ones how would I go about doing  this?  That
> is, {{n1},{n2},.....{2n}} converted to {{n1},{n3}...{2n-1}}. I tried
> using the various procedures in Wolfram's book, but nothing seems to
> work (ie, Delete, Take, etc.).  Thanks for the help.
> Paul Hanson
> --
>                                  * *
>                                 *    *
>                            /\    */\*
>                           /  \   /  \ /\

One efficient way is to create a new list with Table.

list = {{a},{b,c},{d},{e,f,g},{h,a},{k,l,{m,n}},{o,p,q}};

In[6]:= Table[list[[2*j-1]], {j,Quotient[Length[list]+1,2]}] Out[6]=
{{a}, {d}, {h, a}, {o, p, q}}


In[7]:= Table[list[[j]], {j,1,Length[list],2}] Out[7]= {{a}, {d}, {h,
a}, {o, p, q}}

Daniel Lichtblau
Wolfram Research

  • Prev by Date: Re: I don't understand in Mathematic
  • Next by Date: strange behaviour
  • Prev by thread: Re: List Manipulation
  • Next by thread: Impossible?