# Filtering Lists in Mathematica [duplicate]

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}}


• Have a look at Select or Cases or DeleteCases. Dec 20, 2012 at 8:32
• Possible duplicate: mathematica.stackexchange.com/q/2486/121 (I'll let others decide.) Dec 20, 2012 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). Dec 20, 2012 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. Dec 20, 2012 at 8:59
• @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. Dec 20, 2012 at 9:22

 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}} *)

• 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. Dec 20, 2012 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. Dec 20, 2012 at 8:52
• 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.
– kglr
Dec 20, 2012 at 9:05
• 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. Dec 20, 2012 at 9:15
• @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). Dec 20, 2012 at 9:20