jkeenan1 has asked for the wisdom of the Perl Monks concerning the following question:
You have 2 or more lists, each holding 1 or more strictly increasing integers. None of the lists intersect with any of the others. There may be gaps between the last (highest) value of one list and the first (lowest) value of the next list (next in the sense of the lists being ordered by their lowest values). Example:
(1..17); (25..42); (44..50);
Given two non-equal integers, m and n, generate a list of all integers between by concatenating (a) the already extant lists, or parts thereof; and (b) new lists to supply integers falling (i) below the first list, (ii) between any two extant lists, or (iii) above the last list.
With the lists above, and given:
m = 12; n = 62;
then the list (12 .. 62) would be built up from the following components:
(12..17); # sublist of the 1st list (18..24); # gap-filling list (25..42); # entirety of the 2nd list (43); # gap-filling list (44..50); # entirety of the 3rd list (51..62); # integers needed above highest list
I know I could figure this out if I had some spare cycles, but why re-invent the wheel? Thanks in advance.
Jim Keenan
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Gap-filling lists
by davidrw (Prior) on Mar 27, 2006 at 03:00 UTC | |
|
Re: Gap-filling lists
by BrowserUk (Patriarch) on Mar 27, 2006 at 03:26 UTC | |
|
Re: Gap-filling lists
by gaal (Parson) on Mar 27, 2006 at 05:40 UTC |