Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Possible Duplicate:
Select/Delete with Sublist elements?

I need help in filtering long lists of x,y coordinates.Lets use the following list as an example:

list={{3,5},{7,6},{15,6},{23,123}}

I need to filter out all the data points for which x<10. Therefore once the filtering is complete the new list should be:

newlist={{15,6},{23,123}}

Please help.Thank you!

share|improve this question
1  
Have a look at Select or Cases or DeleteCases. –  b.gatessucks Dec 20 '12 at 8:32
    
Possible duplicate: mathematica.stackexchange.com/q/2486/121 (I'll let others decide.) –  Mr.Wizard Dec 20 '12 at 8:48
    
@Mr.Wizard I´d say no duplicate here but I have the feeling there is one out there (did not find it yet). –  Yves Klett Dec 20 '12 at 8:57
    
@Yves anyone who reads and understands the answers to the linked question will immediately know how to solve this one. On that basis I think it is a duplicate. –  Mr.Wizard Dec 20 '12 at 8:59
1  
@Yves I just closed this based on Raghav's comment below. Please let me know if you find a more appropriate duplicate. If you disagree with the closure vote to re-open; I will not overrule that. –  Mr.Wizard Dec 20 '12 at 9:22
show 3 more comments

marked as duplicate by Mr.Wizard Dec 20 '12 at 9:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

up vote 5 down vote accepted
 list = {{3, 5}, {7, 6}, {15, 6}, {23, 123}}

 DeleteCases[list, {x_, _} /; x < 10]
 DeleteCases[list, {_?(# < 10 &), _}]
 Cases[list, {x_, _} /; x >= 10]
 Cases[list, {_?(# >= 10 &), _}]
 Select[list, First[#] >= 10 &]
 Pick[list, First[#] >= 10 & /@ list]
 list /. {x_, _} /; x < 10 :> Sequence[]
 list /. {_?(# < 10 &), _} :> Sequence[]
 (* {{15, 6}, {23, 123}} *)
share|improve this answer
2  
kguler, I'm certain this question is a duplicate. Please consider applying your effort to find the original, rather than posting an answer. Of course if you are unable to find the original (even if you know it's out there somewhere) go ahead and answer. –  Mr.Wizard Dec 20 '12 at 8:37
    
The "duplicate" I found is linked above. I posted my own answer, and voted for yours, as I suppose it could be argued that it is not a duplicate. Nevertheless I think it is, but I didn't want to cast a binding vote. –  Mr.Wizard Dec 20 '12 at 8:52
1  
Mr.W I too was certain that we have seen this question before, and did spend more time to search than to type the answer:), But to my surprise, in my search with the keywords Cases, Select, Pick the Q/A's I found were all related to more complex cases than this one or had some "more advanced" elements. Somehow, I missed the Q/A you linked to. –  kguler Dec 20 '12 at 9:05
1  
Thank you for your help! I tried searching for similar posts but I could not find one. @Mr.Wizard I saw your link and understood how to solve my own problem so thank you for that. –  Raghav Dec 20 '12 at 9:15
1  
@Raghav welcome to Mathematica.SE. You're welcome. Based on your recognition that the answer to the linked question were sufficient for you to solve your problem I am going to close your question as a duplicate. Please do not look upon this as anything other than a housekeeping measure, which it is. Thank you for trying to find a similar question before posting one of your own; I know that is often not easy (Google sometimes helps). –  Mr.Wizard Dec 20 '12 at 9:20
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.