AssociationThread

AssociationThread[{key1,key2,}{val1,val2,}]

gives the association key1val1,key2val2,.

AssociationThread[{key1,key2,},{val1,val2,}]

also gives the association key1val1,key2val2,.

Details

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

Examples

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]=

See Also

Association  AssociationMap  Thread  Transpose  SparseArray

Introduced in 2014
(10.0)