Hi all! I've found the range_to and range_until functions in the builtins, which the numbers use in their to and until methods, but they only go in ascending direction. I would need a descending version of that to use it in a for loop for n in [5, 4, 3, 2, 1, 0]. I think this is a pretty common operation. How we'd want that to look like ideally?
5.down_to(0)0.to(5).reverse(), where "something-something iterators will solve the perf problem"Should range_to and range_until just also work in reverse? 5.range_to(0)? I guess maybe that is more accidentally error prone. 1.range_to(x) (unclear if forward or reverse).
in the future I want ranges to return iterators, which can be reversed
so that would take care of all of those use cases hopefully!
we don't have Iter in builtins yet though
Shall I implement a rev / reverse / reversed method on List in pure Roc, so that the api is there? I vaguely remember you wanting to implement iterators in a way where the user would interact mainly / exclusively with Lists, but that could have changed.
yeah List.rev sounds like a good thing to have anyway!
Last updated: Mar 20 2026 at 12:28 UTC