Merge

Merge[{assoc1,assoc2,},f]

merges the associations associ, using the function f to combine values with the same key.

Merge[{key1val1,key2val2,},f]

gives an association in which values corresponding to identical keys are combined using f.

Merge[f]

represents an operator form of Merge that can be applied to an expression.

Details

  • Merge can operate on any combination of associations and lists of rules.
  • In Merge[expr,f], the function f is applied to lists of values that share the same key.
  • Merge[f][expr] is equivalent to Merge[expr,f].

Examples

open allclose all

Basic Examples  (4)

Merge two associations, using Total to combine elements with the same key:

Combine values corresponding to identical keys into lists:

Combine rules with the same left-hand side:

Create a Merge operator:

Scope  (1)

Combine mixed list entries:

Properties & Relations  (1)

Using a combiner function is equivalent to using Map:

Wolfram Research (2014), Merge, Wolfram Language function, https://reference.wolfram.com/language/ref/Merge.html.

Text

Wolfram Research (2014), Merge, Wolfram Language function, https://reference.wolfram.com/language/ref/Merge.html.

CMS

Wolfram Language. 2014. "Merge." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Merge.html.

APA

Wolfram Language. (2014). Merge. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Merge.html

BibTeX

@misc{reference.wolfram_2024_merge, author="Wolfram Research", title="{Merge}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/Merge.html}", note=[Accessed: 03-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_merge, organization={Wolfram Research}, title={Merge}, year={2014}, url={https://reference.wolfram.com/language/ref/Merge.html}, note=[Accessed: 03-December-2024 ]}