KeyIntersection[{assoc1,assoc2,…}]
generates a list of associations in which only elements whose keys appear in all the associ are retained.
KeyIntersection
KeyIntersection[{assoc1,assoc2,…}]
generates a list of associations in which only elements whose keys appear in all the associ are retained.
Details
- KeyIntersection returns a list of associations in which all the associations have keys ordered in the same way.
- The keys appear in order of their first occurrence in the sequence of associ.
- KeyIntersection can be used not only on Association objects, but also on lists of rules.
Examples
Basic Examples (4)
Generate a list of associations with common keys:
KeyIntersection[{<|a -> 1, b -> 2|>, <|a -> 3, c -> 4|>}]Generate associations from lists:
KeyIntersection[{{a -> 1, b -> 2}, {a -> 3, c -> 4}}]Generate associations from a mixed set:
KeyIntersection[{{a -> 1, b -> 2}, <|a -> 3, c -> 4|>}]KeyIntersection reorders keys to be in the same order:
KeyIntersection[{{a -> 1, b -> 2}, {b -> 1, a -> 2}}]See Also
Related Guides
History
Text
Wolfram Research (2014), KeyIntersection, Wolfram Language function, https://reference.wolfram.com/language/ref/KeyIntersection.html.
CMS
Wolfram Language. 2014. "KeyIntersection." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/KeyIntersection.html.
APA
Wolfram Language. (2014). KeyIntersection. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/KeyIntersection.html
BibTeX
@misc{reference.wolfram_2026_keyintersection, author="Wolfram Research", title="{KeyIntersection}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/KeyIntersection.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_keyintersection, organization={Wolfram Research}, title={KeyIntersection}, year={2014}, url={https://reference.wolfram.com/language/ref/KeyIntersection.html}, note=[Accessed: 12-June-2026]}