randy3k / collections

High-performance container datatypes for R
https://randy3k.github.io/collections
Other
103 stars 3 forks source link

Is there a convenience function for merging dictionaries? #18

Closed travis-leith closed 4 years ago

travis-leith commented 4 years ago

Maybe something like dict(dict1, dict2, dict3, ...)

Collisions can be handled by taking either the first or last value for the same key.

randy3k commented 4 years ago

There is a update method for the dict objects. You may want to check it out.

travis-leith commented 4 years ago

Is it correct to say that my pseudo code above would be properly translated as the following?

dictMerged <- dict1
dictMerged$update(dict2)
dictMerged$update(dict3)
randy3k commented 4 years ago

You could chain the operations together. d1$update(d2)$update(d3). However notice that d1 is modified in place.