Loops/Wrong ranges: Difference between revisions
Content added Content deleted
Line 557: | Line 557: | ||
In both instances (below), it is a precondition (Design by Contract) error to attempt to step negative in a positive stepping iterator. If you want to go backwards, then do a reverse call on the cursor and provide a positive step value. Even in the example provided, these are logic errors (bugs) and not real examples of correct code. |
In both instances (below), it is a precondition (Design by Contract) error to attempt to step negative in a positive stepping iterator. If you want to go backwards, then do a reverse call on the cursor and provide a positive step value. Even in the example provided, these are logic errors (bugs) and not real examples of correct code. |
||
1. ⟳ ic:(-2 |..| 2).new_cursor - 1 ¦ do_nothing ⟲ |
1. ⟳ ic:(-2 |..| 2).new_cursor - 1 ¦ do_nothing ⟲ |
||
2. ⟳ ic:(2 |..| 2).new_cursor - 1 ¦ do_nothing ⟲ |
2. ⟳ ic:(2 |..| 2).new_cursor - 1 ¦ do_nothing ⟲ |
||