Re: Selecting Many Things Rather Than Selecting One Thing From Many

*To*: mathgroup at smc.vnet.net*Subject*: [mg66203] Re: Selecting Many Things Rather Than Selecting One Thing From Many*From*: Gregory Lypny <gregory.lypny at videotron.ca>*Date*: Thu, 4 May 2006 05:20:01 -0400 (EDT)*References*: <e39k7e$cno$1@smc.vnet.net> <44588996.4040309@metrohm.ch>*Sender*: owner-wri-mathgroup at wolfram.com

Thank you, Daniel. I had toyed with the idea of using MemberQ, but never would have thought of the second argument, #[[1]]&. Regards, Gregory On Wed, May 3, 2006, at 6:44 AM, dh wrote: > Hi Gregory, > try: > Select[theMatrix, MemberQ[K,#[[1]]]& ] > > Daniel > > Gregory Lypny wrote: >> Hello everyone, >> I've discovered another use or need for the Select function, which >> I suspect requires mapping of some sort. >> In my previous posts, members of this MathGroup kindly showed me >> how to apply Select to many columns of a matrix at once. For >> example, >> (Select[#1, #1 > K & ] & ) /@ Transpose[theMatrix] >> will pull out all values greater than K, where K is a number such >> as 100. >> But suppose now that K is a list of numbers, such as K={34, 876, >> 199}, and I simply want to extract or identify all of the rows in >> the first column of theMatrix equal to any one of those numbers. >> How would I do that? I started with >> Select[theMatrix, #[[1]]==any element of list K] >> and I imagine something similar could be applied to the Position >> function. >> Any hint would be much appreciated. >> Gregory >