Hi !
I propose modifing Tuple.insert_at/3 and Tuple.delete_at/2 to
allow neg_integer index, like Enum.at/3
Specifically, I would like to fix as below. (and delete insert_at and delete_at
from elixir_rewrite.erl)
@spec insert_at(tuple, integer, term) :: tuple
def insert_at(tuple, index, value) do
non_neg_index =
if index >= 0 do
index
else
count = tuple_size(tuple)
index + count + 1
end
:erlang.insert_element(non_neg_index + 1, tuple, value)
end
@spec delete_at(tuple, integer) :: tuple
def delete_at(tuple, index) do
non_neg_index =
if index >= 0 do
index
else
count = tuple_size(tuple)
index + count
end
:erlang.delete_element(non_neg_index + 1, tuple)
end
--
You received this message because you are subscribed to the Google Groups
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elixir-lang-core/39c5111c-892a-4923-84d4-13450d48211a%40googlegroups.com.