MathGroup Archive 1999

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

Search the Archive

Re: checking for overlap


DennisW555 <dennisw555 at aol.com> wrote in message
news:7ssfbm$bgd at smc.vnet.net...
> I am looking for an elegant way of checking for overlap.
>
> Suppose I have a set of time intervals given by
> ints = {{t1,t2},{t3,t4},{t5,t6}. ...} and another set of times
> tvals = {u1,u2,u3, ...}.
>  What is a fast, elegant way of checking which of the tvals is within any
of
> the ints time intervals?
>
> Thanks,
> Dennis
>

Dennis,


ints = Table[Random[], {7}, {2}];
tvals = Table[Random[], {9}];

Cases[Outer[List, tms, ints, 1],
  {t_, {a_, b_}} /; a <= t <= b, {2}]

If the tvals are also intervals and you are interested in containment, then
a similar code works.
--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565






  • Prev by Date: Is it possible to start a perl executable from mathematica?
  • Next by Date: Re: NSolve with conditions
  • Previous by thread: Re: checking for overlap
  • Next by thread: Re: checking for overlap