Skip to content

Commit 8ab8308

Browse files
vonagamlpil
authored andcommitted
Remove need for reverse in list.range
1 parent a5519c3 commit 8ab8308

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/gleam/list.gleam

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,9 +1289,9 @@ pub fn range(from start: Int, to stop: Int) -> List(Int) {
12891289

12901290
fn tail_recursive_range(start: Int, stop: Int, acc: List(Int)) -> List(Int) {
12911291
case int.compare(start, stop) {
1292-
order.Eq -> reverse([stop, ..acc])
1293-
order.Gt -> tail_recursive_range(start - 1, stop, [start, ..acc])
1294-
order.Lt -> tail_recursive_range(start + 1, stop, [start, ..acc])
1292+
order.Eq -> [stop, ..acc]
1293+
order.Gt -> tail_recursive_range(start, stop + 1, [stop, ..acc])
1294+
order.Lt -> tail_recursive_range(start, stop - 1, [stop, ..acc])
12951295
}
12961296
}
12971297

0 commit comments

Comments
 (0)