Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Take and drop particular keys in an association
ResourceFunction["KeyTakeDrop"][assoc,{key1,key2,…}] gives the pair {assoc1,assoc2}, where assoc1 contains only the elements with keyi and assoc2 contains no elements with keyi. | |
ResourceFunction["KeyTakeDrop"][{assoc1,assoc2,…},{key1,key2,…}] gives a list of association pairs. | |
ResourceFunction["KeyTakeDrop"][keys] represents an operator form of ResourceFunction["KeyTakeDrop"] that can be applied to an expression. |
Take and drop rules from an association, given a list of keys:
In[1]:= |
Out[1]= |
Take and drop from several associations, given a list of keys:
In[2]:= |
Out[2]= |
Take and drop rules from a list to create a pair of associations:
In[3]:= |
Out[3]= |
Take and drop rules from several lists:
In[4]:= |
Out[4]= |
Take and drop from an association, using a single key:
In[5]:= |
Out[5]= |
Take and drop from a list, using a single key:
In[6]:= |
Out[6]= |
Use the operator form of KeyTakeDrop:
In[7]:= |
Out[7]= |
Non-existing keys are ignored:
In[8]:= |
Out[8]= |
When a list of rules has a repeated key, only the last value is maintained in the output:
In[9]:= |
Out[9]= |
This work is licensed under a Creative Commons Attribution 4.0 International License