MathGroup Archive 2002

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

Search the Archive

Re: List processing


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



  • Prev by Date: Re: List processing
  • Next by Date: Get rid of unwanted {}
  • Previous by thread: Re: List processing
  • Next by thread: Re: List processing