Skip to content

Merge

Status: Stable

documented, exercised by the test suite and/or worked examples, with no known limitations recorded.

Description

Merge[{assoc1, assoc2, ...}, f]
    Combines associations, applying f to the list of values collected
    for each key (e.g. Merge[{...}, Total]).

Examples

All examples below are verified against the current Mathilda build.

In[1]:= Merge[{<|"a" -> 1|>, <|"a" -> 2, "b" -> 3|>}, Total]
Out[1]= <|"a" -> 3, "b" -> 3|>

In[2]:= Merge[<|"g1" -> <|"a" -> 1|>, "g2" -> <|"a" -> 2, "b" -> 3|>|>, Total]
Out[2]= <|"a" -> 3, "b" -> 3|>

Implementation notes

Attributes: Protected.

Implementation status

Stable — documented, exercised by the test suite and/or worked examples, with no known limitations recorded.

References