Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
43
Task/Associative-array-Merging/00-TASK.txt
Normal file
43
Task/Associative-array-Merging/00-TASK.txt
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
;Task:
|
||||
Define two associative arrays, where one represents the following "base" data:
|
||||
|
||||
::::: {| class="wikitable"
|
||||
|+
|
||||
| '''Key''' || '''Value'''
|
||||
|-
|
||||
| "name" || "Rocket Skates"
|
||||
|-
|
||||
| "price" || 12.75
|
||||
|-
|
||||
| "color" || "yellow"
|
||||
|}
|
||||
|
||||
And the other represents "update" data:
|
||||
|
||||
::::: {| class="wikitable"
|
||||
|+
|
||||
| '''Key''' || '''Value'''
|
||||
|-
|
||||
| "price" || 15.25
|
||||
|-
|
||||
| "color" || "red"
|
||||
|-
|
||||
| "year" || 1974
|
||||
|}
|
||||
|
||||
Merge these into a new associative array that contains every key found in either of the source ones. Each key should map to the value in the second (update) table if that exists, or else to the value in the first (base) table. If possible, do this in a way that does not mutate the original two associative arrays. Obviously this should be done in a way that would work for any data, not just the specific data given here, but in this example the result should be:
|
||||
|
||||
::::: {| class="wikitable"
|
||||
|+
|
||||
| '''Key''' || '''Value'''
|
||||
|-
|
||||
| "name" || "Rocket Skates"
|
||||
|-
|
||||
| "price" || 15.25
|
||||
|-
|
||||
| "color" || "red"
|
||||
|-
|
||||
| "year" || 1974
|
||||
|}
|
||||
<br><br>
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue