KeyIntersection

KeyIntersection[{assoc1,assoc2,}]
generates a list of associations in which only elements whose keys appear in all the are retained.

DetailsDetails

  • 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 .
  • KeyIntersection can be used not only on Association objects, but also on lists of rules.

ExamplesExamplesopen allclose all

Basic Examples  (4)Basic Examples  (4)

Generate a list of associations with common keys:

In[1]:=
Click for copyable input
Out[1]=

Generate associations from lists:

In[1]:=
Click for copyable input
Out[1]=

Generate associations from a mixed set:

In[1]:=
Click for copyable input
Out[1]=

KeyIntersection reorders keys to be in the same order:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2014
(10.0)