MathGroup Archive 2002

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

Search the Archive

Re: List processing

  • To: mathgroup at
  • Subject: [mg37224] Re: List processing
  • From: "Allan Hayes" <hay at>
  • Date: Thu, 17 Oct 2002 00:08:58 -0400 (EDT)
  • References: <aokbp7$afv$>
  • Sender: owner-wri-mathgroup at

"John Leary" <leary at> wrote in message
news:aokbp7$afv$1 at
> 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
> in {{100,270},{300,400}}.


Generate a list of pairs:


A slow solution


{5. Second,{{0,219},{221,431},{432,568},{569,599},{600,697},{699,1005}}}

A faster one

FixedPoint[{Min[#],Max[#]}&/@Split[Sort[#], #1[[2]]>=#2[[1]]&]&,

{0.22 Second,{{0,219},{221,431},{432,568},{569,599},{600,697},{699,1005}}}


Allan Hayes
Mathematica Training and Consulting
Leicester UK
hay at
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

  • Prev by Date: Re: grouping and averaging {x,y} pairs of data
  • Next by Date: Re: List processing
  • Previous by thread: RE: List processing
  • Next by thread: Re: List processing