put in
place a value in a nested data structure
(any xs, list keys, any value) -> any
Given a dict or list of xs
, returns the same type of collection with value
placed at the end of navigating through the list of keys
.
If any intermediate structures have to be created, they will be, depending on key type. String keys create dicts. Long keys create lists.
If a value
is placed in a list, any undefined indexes are filled with nil
.
Returns nil
if xs
is nil
.
Throws an error if xs
is neither a dict nor a list.
Throws an error if xs
keys is nil
.
Throws an error when trying to access a data structure that is neither a dict or list.
Throws an error or when a key value cannot be cast to the appropriate key type of the data structure.
Parameters
Name | Type | Description |
---|---|---|
xs |
dict or list | The dict or list to work with |
keys |
list | The keys and indexes to traverse |
value |
any |
The value to place in xs |