Re: List processing
- To: mathgroup at smc.vnet.net
- Subject: [mg37249] Re: List processing
- From: "Carl K. Woll" <carlw at u.washington.edu>
- Date: Fri, 18 Oct 2002 05:17:36 -0400 (EDT)
- Organization: University of Washington
- References: <aokbp7$afv$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi John,
I remember there being a similar thread on this subject a while ago, but I
am too lazy to check it out. The simplest solution seems to be using
Interval, although it may not be very fast. For example
In[3]:=
Interval[{100,200},{150,250},{120,270},{300,400}]
Out[3]=
Interval[{100, 270}, {300, 400}]
If the above is not sufficiently fast for you, then you may want to search
the archives for the thread I mentioned above.
Carl Woll
Physics Dept
U of Washington
"John Leary" <leary at paradise.net.nz> wrote in message
news:aokbp7$afv$1 at smc.vnet.net...
> Greetings
>
> This problem can be solved by conventional programming, but I wonder if
> there is an elegant Mathematica solution ?
>
> A list contains pairs of values, with each pair representing the lower and
> upper edge of a sub-range. Some of the sub-ranges partially overlap, some
> fully overlap, others don't overlap at all. The problem is to produce a
> second list that contains the overall upper and lower edges of the
> overlapping sub-ranges.
>
> A simple example : {{100,200},{150,250},{120,270},{300,400}} would
result
> in {{100,270},{300,400}}.
>
> In the real case, the input list has several hundred elements and the
> output list typically has five elements.
>
> I have a working solution based on loops, but there must be a more elegant
> one. I would be very grateful for any suggestions.
>
>
> Best regards
>
> John Leary
>
>