Assoc¶
Name | - | Description | Default | Type |
---|---|---|---|---|
<input> |
Input sequence that defines which element in the target sequence or table needs to be updated and with what value. Should have even number of elements. | [Any] |
||
<output> |
Modified array or table. Has the same type as the array or table on which Assoc was applied. | [Any] |
||
Name |
The name of the sequence or table to be updated. | "" |
String &Any |
|
Key |
Table key for the value that is to be updated. Parameter applicable if target is table. | None |
String &String |
|
Global |
If the variable is or should be available to all the wires in the same mesh. The default value (false) makes the variable local to the wire. | false |
Bool |
Updates a sequence (array) or a table (associative array/ dictionary) on the basis of an input sequence.
Details¶
This shard can be used to update specific member elements within a sequence or a table with new values.
The input sequence identifies which elements are to be updated and their new/ updated values. To achieve this, the member elements of this input sequence are parsed in pairs. The 1st element of each pair gives the index of the target element to update, and the 2nd element of that pair gives the new value for the target element. Due to this, the input sequence must always contain an even number of elements.
Examples¶
1 2 3 4 5 6 |
|
[info] [shards/General/Assoc/1.edn] [10 20]
[info] [shards/General/Assoc/1.edn] [2 3]
1 2 3 4 5 6 |
|
[info] [shards/General/Assoc/2.edn] {key1: [10 20] key2: [30 40]}
[info] [shards/General/Assoc/2.edn] {key1: [2 3] key2: [30 40]}
1 2 3 4 5 6 |
|
[info] [shards/General/Assoc/3.edn] {key1: [10 20] key2: [30 40]}
[info] [shards/General/Assoc/3.edn] {key1: [10 20] key2: [2 3]}