Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Convert a list of pairs into an association
| ResourceFunction["AssociatePairs"][{{key1,val1},{key2,val2},…}] gives the Association <|key1→val1,key2→val2, …|>. | 
Make an Association:
| In[1]:= | ![ResourceFunction["AssociatePairs"][{{a, 1}, {b, 2}, {c, 3}}]](https://www.wolframcloud.com/obj/resourcesystem/images/615/615c5d2b-533c-48f7-af2a-783a858da9e4/0b1614e4ba1dc6fb.png) | 
| Out[1]= |  | 
Make an Association from two lists:
| In[2]:= | ![ResourceFunction["AssociatePairs"][Transpose[{{a, b, c}, Range[3]}]]](https://www.wolframcloud.com/obj/resourcesystem/images/615/615c5d2b-533c-48f7-af2a-783a858da9e4/4487034a494e2d2f.png) | 
| Out[2]= |  | 
The number of moons for each planet in the solar system:
| In[3]:= | ![ResourceFunction["AssociatePairs"][
 PlanetData[#, {"Name", "MoonCount"}] & /@ PlanetData[]]](https://www.wolframcloud.com/obj/resourcesystem/images/615/615c5d2b-533c-48f7-af2a-783a858da9e4/4405de90448d4bac.png) | 
| Out[3]= |  | 
AssociatePairs does not thread over lists:
| In[6]:= | ![ResourceFunction[
 "AssociatePairs"][{{{r, s}, {t, u}}, {{w, x}, {y, z}}}]](https://www.wolframcloud.com/obj/resourcesystem/images/615/615c5d2b-533c-48f7-af2a-783a858da9e4/1e122ee136077e8f.png) | 
| Out[6]= |  | 
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License