Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Map a function over the keys of an association, and collect or combine values in the event of key collisions
ResourceFunction["KeyCombine"][f,assoc] maps f over the keys in assoc and collects values having the same key into a list. | |
ResourceFunction["KeyCombine"][f,assoc,comb] uses the combiner function comb to combine values having the same key. | |
ResourceFunction["KeyCombine"][f] represents an operator form of ResourceFunction["KeyCombine"] that can be applied to an expression. |
Sort the keys of an association and collect values that end up having the same key:
| In[1]:= |
| Out[1]= |
Sum values instead of collecting them:
| In[2]:= |
| Out[2]= |
Convert frequency data (counts) created using a bin size of 1 to a bin size of 3:
| In[3]:= |
| Out[3]= |
| In[4]:= |
| Out[4]= |
Combine reciprocal edges of a weighted, directed graph using geometric mean:
| In[5]:= |
| In[6]:= |
| Out[6]= | ![]() |
| In[7]:= |
| Out[7]= | ![]() |
KeyCombine does not change the ordering of keys:
| In[8]:= |
| Out[8]= |
This work is licensed under a Creative Commons Attribution 4.0 International License