Re: List processing

• To: mathgroup at smc.vnet.net
• Subject: [mg37219] Re: List processing
• From: tdelling at glsn12.ews.uiuc.edu (Tim Dellinger)
• Date: Thu, 17 Oct 2002 00:08:44 -0400 (EDT)
• Organization: University of Illinois at Urbana-Champaign
• References: <aokbp7\$afv\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```John Leary <leary at paradise.net.nz> writes:

>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.

If the numbers are all integers less than 401, as in your example,
number to every pair in your list-of-pairs.  If there exists no pair
that the given number falls between (inclusive), replace the number with zero.

Converting the resulting list to the output you want "is an exercise
for the reader" (clever replacement rules will do it easily).

--
Tim Dellinger                                www.ews.uiuc.edu/~tdelling
tdelling at uiuc.edu

```

• Prev by Date: Re: List processing
• Next by Date: RE: How to speed up this calculation?
• Previous by thread: Re: List processing
• Next by thread: Re: List processing