Using Select within Map

• To: mathgroup at smc.vnet.net
• Subject: [mg71758] Using Select within Map
• From: Mark Teagarden <Mark.Teagarden at utsa.edu>
• Date: Tue, 28 Nov 2006 06:04:12 -0500 (EST)

```Hi,

I have a data set which comprises several paired lists, like so (I apologize
if the tabs do not come out correctly in your mail client):

x =
{
{
{ , },
{ , },
{ , }
},
{
{ , },
{ , },
{ , }
},
{
{ , },
{ , },
{ , }
}
}

What I would like to do is to select from each of those paired lists, only
those pairs where the first value in the pair falls within some specified
range, and then obtain a mean.  This would be simple enough if I was
operating on a single paired list, for example:

Select[x[[1]],a < #[[1]] < b&]

However, I would like to Map over x so that I would end up with means for
each of the level 1 lists within x; therein lies the problem.  Both Map and
Select use the Slot operator (#), and I don't know how to distinguish
between the slot operator used by Map, and the slot operator used by Select:

Select[#,a < #[[1]] < b&]/@x

Or if you prefer:

Map[Select[#, a < #[[1]] < b&,x]

This problem has been plaguing me for some time, and if I could punch
through it I would be very happy indeed.  Any ideas?  I have had no luck
looking through the archives or the Help Browser.  On a similar note, I
would eventually like to modify this solution so that the criteria, a and b,
could vary with each level 1 list in x, but one thing at a time...

Mark

--
Mark A. Teagarden, Ph.D.
University of Texas at San Antonio
Department of Biology
One UTSA Circle
San Antonio, TX 78249

```

• Prev by Date: Re: Area of ellipse between major axis and ray through focus, given angle
• Next by Date: RE: pattern matching: rules that stop other rules?
• Previous by thread: RE: Functional decomposition (solving f[f[x]] = g[x] for given g)
• Next by thread: Re: Using Select within Map