List.insert_at
You're seeing just the function
insert_at
, go back to List module for more information.
Specs
Returns a list with value
inserted at the specified index
.
Note that index
is capped at the list length. Negative indices
indicate an offset from the end of the list
.
Examples
iex> List.insert_at([1, 2, 3, 4], 2, 0)
[1, 2, 0, 3, 4]
iex> List.insert_at([1, 2, 3], 10, 0)
[1, 2, 3, 0]
iex> List.insert_at([1, 2, 3], -1, 0)
[1, 2, 3, 0]
iex> List.insert_at([1, 2, 3], -10, 0)
[0, 1, 2, 3]