Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: Segregating the elements of a list based on given lower and upper bounds

  • To: mathgroup at smc.vnet.net
  • Subject: [mg77314] Re: [mg77205] Segregating the elements of a list based on given lower and upper bounds
  • From: "R.G" <gobiithasan at yahoo.com.my>
  • Date: Wed, 6 Jun 2007 07:29:30 -0400 (EDT)

Hi DrMajorBob, Excellent piece of code! Thanks!
R.G
--- DrMajorBob <drmajorbob at bigfoot.com> wrote:

> Clear[inbounds]
> inbounds[{low_?NumericQ, high_?NumericQ}][x_?NumericQ] :=
>   low <= x <= high
> inbounds[{low_?NumericQ, high_?NumericQ}, x_List] :=
>   Select[x, inbounds[{low, high}]]
> inbounds[x_List, y_List] := inbounds[#, x] & /@ y
> Length /@ inbounds[a, b]
> 
> {1, 1, 0, 1, 2}
> 
> Bobby
> 
> On Tue, 05 Jun 2007 05:58:10 -0500, R.G <gobiithasan at yahoo.com.my>
> wrote:
> 
> > Hi Mathgroup members,
> >
> > Say, I have a list with the following elements:
> >
> > A={6.32553, 7.09956, 8.56784, 16.1871, 15.3989, 17.2285, 7.40711, \
> > 14.8876, 19.9068, 10.0834}
> >
> > and I have the following list with each {xvalue, yvalue}={lower
> bound,
> > upper bound}:
> >  B={{0, 7}, {8, 10}, {11, 12}, {13, 15}, {16, 18}}
> >
> > How can I segregate values in A according to lower bound and upper
> > bound from B and find the number number of occurrence ?For example:
> > {0,7}={6.32553}, thus the number of occurrence is 1.
> > {8, 10}={7.09956,7.40711,8.56784}, the number of occurrence is 3.
> > {11,12}=None, the number of occurrence is 0.
> >
> > The code should be able work for any number Length[A] and
> Length[B].
> > Any suggestion please?
> > Thank you,
> > R.G
> >
> >
> >
> 
> 
> 
> -- 
> DrMajorBob at bigfoot.com
> 


Send instant messages to your online friends http://uk.messenger.yahoo.com 


  • Prev by Date: Re: DIfference of error functions with complex arguments
  • Next by Date: Re: NDSolve, Do loop, and Plot
  • Previous by thread: Re: Segregating the elements of a list based on given lower and upper bounds
  • Next by thread: Re: Segregating the elements of a list based on given lower and upper bounds