Commit d22c3a3
authored
Make Flow.range support descending ranges with negative step (#455)
Fixes #439 — Flow.range with a negative step was only emitting the first
element due to incorrect termination logic.
The original implementation used a fixed termination condition (`t <=
to`) that didn't account for negative steps. With a negative step, this
condition would cause the loop to terminate prematurely.
The fix updates the range method to:
- Require non-zero step values
- Use conditional termination logic: `t <= to` for positive steps, `t >=
to` for negative steps
- Document the descending range behavior with examples
Test cases for descending ranges have been added to verify the fix works
correctly.
Closes #439.1 parent f3d5930 commit d22c3a3
2 files changed
Lines changed: 16 additions & 7 deletions
File tree
- core/src
- main/scala/ox/flow
- test/scala/ox/flow
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
95 | 100 | | |
96 | 101 | | |
97 | 102 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
28 | 32 | | |
0 commit comments