http://qs321.pair.com?node_id=892936


in reply to Re^5: Split range 0 to M into N non-overlapping (roughly equal) ranges.
in thread Split range 0 to M into N non-overlapping (roughly equal) ranges.

But this isn't 0 .. 14 inclusive:
[ 6:16:11.35] C:\test>ranges -M=14 -N=11 0 : from 0 to 0 ( 1) 1 : from 1 to 1 ( 1) 2 : from 2 to 3 ( 2) 3 : from 4 to 4 ( 1) 4 : from 5 to 5 ( 1) 5 : from 6 to 7 ( 2) 6 : from 8 to 8 ( 1) 7 : from 9 to 9 ( 1) 8 : from 10 to 11 ( 2) 9 : from 12 to 12 ( 1) 10 : from 13 to 13 ( 1) ======================================== 14

Based on your previous results, I expect non-inclusive every time. If my expectation is wrong, then why is the result above non-inclusive (i.e. does not end with index 14)?

(I'm not adamant on my expectation of non-inclusiveness. I just expect consistent behavior. :-)
  • Comment on Re^6: Split range 0 to M into N non-overlapping (roughly equal) ranges.
  • Download Code

Replies are listed 'Best First'.
Re^7: Split range 0 to M into N non-overlapping (roughly equal) ranges.
by BrowserUk (Patriarch) on Mar 13, 2011 at 07:51 UTC

    Ah! Now I see the problem. (Phraseology lacking).

    Preliminary response:

    my $STEP = ( $M + 1.5 ) / $N;

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.