Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Calculate the overlap length between two ranges

by sundialsvc4 (Abbot)
on Oct 30, 2013 at 14:19 UTC ( #1060384=note: print w/replies, xml ) Need Help??

in reply to Calculate the overlap length between two ranges

Two ranges A and B overlap if low(A) <= high(B) AND high(A) >= low(B) ... hope I got that right, but it’s something like that.   Yes, there should be a CPAN module as-noted which does this simple task and probably others that will be of interest to you.

Then, again IIRC, the distance ought to be something like Max(Low(A), High(B)) - Min(Low(B), High(A)) ... not so sure about that one, it’s been a while.   Anyway, I do remember that you are testing the opposite-end numbers in each pair in some way.

  • Comment on Re: Calculate the overlap length between two ranges

Replies are listed 'Best First'.
Re^2: Calculate the overlap length between two ranges
by Laurent_R (Canon) on Oct 30, 2013 at 18:04 UTC

    Except that the OP did not speak about distance but about "the length between some overlapping numerical ranges", this phrasing does not really make sense to me. The length between overlapping ranges, if anything, is 0. This is why I kindly asked for clarification. Or, perhaps, it is a deficiency in my command of the English language. But the OP answered some later posts by other monks, but did not see it fit to answer mine.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1060384]
[holli]: Alone the chatterbox and everybody writes his own cb client tradition
[LanX]: there was a guy who tried to steal the concept and build an own monastery ...
[LanX]: yeah PM is very emacsy ;-)
[LanX]: I think tobyink was on a good track with his redesign, pitty the pmdevs/gods didn't try to continue the approach of a modern responsive design
[holli]: *sigh* why has there to be drama in such a thread?
[LanX]: ?
[holli]: Re^2: Let's Make PerlMonks Great Again! -- suggestions and dreams - STFU and write code already (start already)

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2017-11-20 19:40 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (292 votes). Check out past polls.