Talk:Range consolidation: Difference between revisions
Content added Content deleted
(→null range: zero-extent ranges) |
|||
Line 25: | Line 25: | ||
==null range== |
==null range== |
||
Is a ''null'' range a legal and valid range? Should programming examples handle (and express) such an animal? -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 07:38, 9 February 2019 (UTC) |
Is a ''null'' range a legal and valid range? Should programming examples handle (and express) such an animal? -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 07:38, 9 February 2019 (UTC) |
||
: If by null range, we are taking of ranges where the two boundaries coincide, then it is a valid range, i guess. |
|||
: A range is defined as having two end points though, in all cases. (for my Python example whee aI use a two-element list or tuple to represent a range, an empty list/tuple is not a valid range). |
|||
: (I had not thought of that, thanks.). |
|||
: This is what the Python solution does with a zero-extent range: |
|||
<pre>consolidate([[1, 1]]) |
|||
Out[2]: [[1, 1]] |
|||
consolidate([[1, 1], [1, 1]]) |
|||
Out[3]: [[1, 1]] |
|||
consolidate([[0, 0], [0, 0]]) |
|||
Out[4]: [[0, 0]] |
|||
consolidate([[1, 1], [0, 2]]) |
|||
Out[5]: [[0, 2]] |
|||
consolidate([[1, 1], [0, 1]]) |
|||
Out[6]: [[0, 1]] |
|||
consolidate([[1, 1], [1, 2]]) |
|||
Out[7]: [[1, 2]]</pre> |
|||
: --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 18:34, 10 February 2019 (UTC) |
|||
==Python tester== |
==Python tester== |