-
-
Notifications
You must be signed in to change notification settings - Fork 215
Open
Description
I found myself needing to implement that function and thought that the usecase is popular enough to warrant a PR stdlib.
This is a variation of range with the user-provided step.
The general use would be:
/// ```gleam
/// range_with_step(1, 5, 2)
/// // -> [1, 3, 5]
/// ```
///
/// ```gleam
/// range_with_step(1, 6, 2)
/// // -> [1, 3, 5]
/// ```
///
/// ```gleam
/// range_with_step(6, -1, -3)
/// // -> [6, 3, 0]
/// ```
///
/// ```gleam
/// range_with_step(6, -3, -3)
/// // -> [6, 3, 0, -3]
/// ```
Discussion (if the idea is not rejected):
- what should happen when given step is 0?
- what should happen when from and to are equal?
- which of the 2 above takes precedence?
- what should happen when (from<to and step<0) or (from>to and step>0)?
- a propos the one above should the function return
List(Int)orResult?
Metadata
Metadata
Assignees
Labels
No labels