update
update a value in a dict or list
(any xs, any key, function f) -> any
Given a dict or list of xs, returns the same type of collection with f(v) placed at key, where v is the original value at xs[key].
If xs is 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 key is nil.
Throws an error if f is nil.
Throws an error if xs is a list and key cannot be cast to a long or key is negative.
Throws an error if xs is a dict and key cannot be cast to a string.
Parameters
| Name | Type | Description |
|---|---|---|
xs |
dict or list | The dict or list to access |
key |
string or long | The key or index to access |
f |
function |
A function of the form (v) -> any that transforms any existing value to the updated value. |