Re: Extraction of positive values from list of both +/- values
- To: mathgroup at smc.vnet.net
- Subject: [mg34651] Re: [mg34637] Extraction of positive values from list of both +/- values
- From: BobHanlon at aol.com
- Date: Fri, 31 May 2002 04:26:29 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 5/30/02 3:24:34 AM, divinesaam at aol.com writes: >I have a list of values: > >lstvals={700, 600, 500, 400, 300, 200, 100, -50, 100, -200, -300} > >I want to create a list that contains only the positive values. I know >I can use > >lst=Take[lstvals, 7] > >The problem is, the size of the vectors vary. Help appreciated. > lstvals={700,600,500,400,300,200,100,-50,100,-200,-300}; Select[lstvals, #>0&] {700, 600, 500, 400, 300, 200, 100, 100} or Cases[lstvals, _?Positive] {700, 600, 500, 400, 300, 200, 100, 100} If you also want to eliminate duplicates use Union Bob Hanlon Chantilly, VA USA