Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5938 > unrolled thread

Re: simple question about removing elements from a table

Started byPete Boardman <pete.boardman@mac.com>
First post2011-10-27 10:44 +0000
Last post2011-10-27 10:44 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: simple question about removing elements from a table Pete Boardman <pete.boardman@mac.com> - 2011-10-27 10:44 +0000

#5938 — Re: simple question about removing elements from a table

FromPete Boardman <pete.boardman@mac.com>
Date2011-10-27 10:44 +0000
SubjectRe: simple question about removing elements from a table
Message-ID<j8bcmo$8tr$1@smc.vnet.net>
On 26 Oct 2011, at 22:37, Michael B. Heaney wrote:

> data={{-0.5, 0.0321787}, {-0.489, 0.0321691}, {-0.478,
> 0.032211}, {-0.467, 0.0321723}, {-0.456, 0.0322448}, {-0.444, 0.0321498},
> {-0.433, 0.032132}, {-0.422, 0.0321804}, {-0.411, 0.0322158},
> {-0.4, 0.0320886},  {-0.233,  0.0320596},  {0.567, 0.00286087}, {0.578,
> -0.00143633}, {0.589, -0.00592979}, {0.6, -0.0113609}}
> I want to remove all of the elements that have a positive first number, to
> get:
> 
> datasubset={{-0.5, 0.0321787}, {-0.489, 0.0321691}, {-0.478,
> 0.032211}, {-0.467, 0.0321723}, {-0.456, 0.0322448}, {-0.444, 0.0321498},
> {-0.433, 0.032132}, {-0.422, 0.0321804}, {-0.411, 0.0322158},
> {-0.4, 0.0320886},  {-0.233,  0.0320596}}
> 
> How do I do this?

I'm a newcomer to Mathematica, but this might be something I can answer... :)

>From the help:

  Select[list,crit] 
     picks out all elements Subscript[e, i] of list for which crit[Subscript[e, i]] is True. 

so you supply the list, followed by a function that selects the elements you want.

Select[data, #[[1]] < 0 &]

where  [[1]] < 0 says the first element is less than 0, and & defines a function that is applied to every 
element of the list, ie the #. 

hth

pete

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web