AssociationThread

AssociationThread[{key1,key2,}{val1,val2,}]
gives the association .

AssociationThread[{key1,key2,},{val1,val2,}]
also gives the association .

DetailsDetails

  • If any of the are repeated, later instances replace earlier ones.
  • AssociationThread[keys:>values] yields an association in which every element uses a delayed rule.

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Create an association from two lists:

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

Repeated keys replace earlier ones:

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

Create an association with delayed values:

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

Get the current date and temperature:

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