insert
insert a value into a list
(list xs, long index, any x) -> list
Returns a list consisting of all elements of xs
, with elements starting at index index
shifted to the right, and x
inserted at position index
. If index
is bigger than the largest index in xs
, any intermediate indexes are created with value nil
.
Returns nil
if xs
is nil
.
Throws an error if index
is negative or nil
.
Parameters
Name | Type | Description |
---|---|---|
xs |
list | The list to modify |
index |
long | The index to insert at |
x |
any |
The value to insert into xs |