Re: List processing
- To: mathgroup at smc.vnet.net
- Subject: [mg37253] Re: List processing
- From: Tom Burton <tburton at brahea.com>
- Date: Fri, 18 Oct 2002 05:18:00 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On 10/16/02 11:39 AM, in article aokbp7$afv$1 at smc.vnet.net, "John Leary"
<leary at paradise.net.nz> wrote:
> 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.
Until recently, this could have been tedious, but now, tada!:
In[31] := data = {{100, 200}, {150, 250}, {120, 270}, {300, 400}};
List @@ IntervalUnion @@ Interval /@ data
Out[31] = {{100, 270}, {300, 400}}
Tom Burton