I’ve been using Odin for a week and making my first project in it, so I might be missing something from core library, but is there a builtin function to shift elements to the right in a slice? This kind of function is useful to delete elements based on a predicate similar to C++'s erase+remove idiom. At the moment, I implement this manually:
slice_shift_right_proc :: proc(xs: $S/[]$T, predicate: proc(x: T) -> bool) -> int {
first, found := slice.linear_search_proc(xs, predicate)
last := len(xs)
if found && first != last {
for i := first; true; {
if !predicate(xs[i]) {
xs[first] = xs[i]
first += 1
}
i += 1
if i >= last do break
}
return first
}
return -1
}