Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Recursively replace lists of rules with associations
ResourceFunction["ToAssociations"][{key1→val1,key2→val2,…}] recursively replaces lists of rules with associations having the same keys and values. |
Convert a list of rules to an Association:
In[1]:= | ![]() |
Out[1]= | ![]() |
Convert a nested list of rules:
In[2]:= | ![]() |
Out[2]= | ![]() |
Convert a mix of associations and rule lists:
In[3]:= | ![]() |
Out[3]= | ![]() |
Convert a mix of lists and associations:
In[4]:= | ![]() |
Out[4]= | ![]() |
List items that are not in the form {key→value,…} are left alone:
In[5]:= | ![]() |
Out[5]= | ![]() |
ToAssociations stops at unevaluated expressions:
In[6]:= | ![]() |
Out[6]= | ![]() |
Evaluate the held part to let ToAssociations continue:
In[7]:= | ![]() |
Out[7]= | ![]() |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License