MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Using Select

  • To: mathgroup at
  • Subject: [mg76162] Using Select
  • From: Mark Coleman <mark at>
  • Date: Thu, 17 May 2007 05:54:35 -0400 (EDT)


I'm working on a small application and I'm searching for a way to  
Select a subset of rows from a list based upon a list of criteria  
chosen by the user.  Here is small (hypothetical) example. Say one  
has a data set of consisting of a list of as follows:

{ {1,A,Blue,"Hello",10.5},{7,D,Green,"Goodbye",9.4}, 

The user will specify a letter and a color and the program should  
Select[ ] the appropriate rows, e.g., if I pick Color=Blue and Letter  
= A, then it will return

{ {1,A,Blue,"Hello",10.5},{3,A,Blue,"Hello",8.0}....}, etc.  Thus one  
can enter Select[myData,(#[[2]]==A && #[[3]]==Blue)&] and get the  
appropriate records.Note that The actual data set has about 20,000  
records (lists), each with about 20 fields, and can select 7 or 8  
different attributes, so the Select statements get fairly long.

My question involves an efficient way to code the Select statement if  
a user wants to chose records that correspond to any value of a  
particular field, e.g., All of the Color=Blue, regardless of the  
Letter choice,e.g.,


More precisely, is there a way to pass Select the user choice of any  
letter using some sort of 'wildcard' value that represents any value  
for the specific attribute, i.e.,

  Select[myData,(#[[2]]=='Wildcard' && #[[3]]==Blue)&]

My motivation is that if I have may possible selection criteria, I  
can still use a single Select statement.



  • Prev by Date: Re: Re: Re: Where is the Mathematica
  • Next by Date: Re: Residue Function
  • Previous by thread: Re: how save newly created palette?
  • Next by thread: Re: Using Select