Skip to content

Commit

Permalink
Add reverse function to array module
Browse files Browse the repository at this point in the history
  • Loading branch information
tjammer committed Sep 9, 2024
1 parent 76a6062 commit c8aa490
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions std/array.smu
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ fun reserve(arr&, size) {
}
}

fun reverse(arr&) {
let length = length(arr)
iter_range(0, length / 2, fun i {
swap_items(&arr, i, length - i - 1)
})
}

module fixed {
let get = __fixed_array_get
let length = __fixed_array_length
Expand Down
1 change: 1 addition & 0 deletions std/prelude.smu
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
let + = __addi
let - = __subi
let * = __multi
let / = __divi
let /. = __divf
let < = __lessi
let <= = __lesseqi
Expand Down

0 comments on commit c8aa490

Please sign in to comment.