in reply to eliding number ranges

Interesting to notice how the collection of test cases is growing as monks review other monk suggestions. Reminds me of XP's Test-Driven Development except in reverse.

To consolidate -

__DATA__ 1 32 2 20 2 21 4 19 28 31 28 39 34 123 51 1 199 200 199 201 321 321 324 329 325 349 340 509 999 1000 1000 1001 1999 2000

PS: The unusual case of  51   1  doesn't work with Abigail's code but could be fixed easily, perhaps with  ($f,$s) = ($s,$f) if $s < $f;

 

Replies are listed 'Best First'.
Re: Re: eliding number ranges
by qq (Hermit) on Nov 15, 2003 at 13:01 UTC

    Indeed - its not always easy to tell which tests you'll need in advance. But once you do add them, they're there for good.

    And my original "solution" fails on a couple of these as well.

    qq