Re: List Manipulation (2)
- To: mathgroup@smc.vnet.net
- Subject: [mg10676] Re: List Manipulation (2)
- From: Allan Hayes <hay@haystack.demon.co.uk>
- Date: Fri, 30 Jan 1998 04:24:15 -0500
- References: <69nbfq$89h@smc.vnet.net> <6ahlgq$p76@smc.vnet.net>
Paul.Hanson@colorado.edu wrote: > 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}}. Paul: Here is another way: lst = {{a},{b,c},{d},{e,f,g},{h,a},{k,l,{m,n}},{o,p,q}}; lst[[Table[i,{i,1,Length[lst],2}]]] {{a},{d},{h,a},{o,p,q}} It's slightly slower than my earlier posting, which used Partition, but the increased flexibility is valuable. tst = Table[i, {10000},{i,Random[Integer,100]}]; Partition[tst,1,2,Sequence];//Timing//First 0.166667 Second tst[[Table[i,{i,1,Length[tst],2}]]];//Timing//First 0.183333 Second -- Allan Hayes Mathematica Training and Consulting Leicester, UK hay@haystack.demon.co.uk http://www.haystack.demon.co.uk voice: +44 (0)116 271 4198 fax: +44 (0)116 271 8642