Enhanced Association Tools Now Available in the Wolfram Function Repository
Association has become one of the most commonly used symbols for developers working with any kind of data since it was introduced in Version 10 of the Wolfram Language in 2014. While there are many built-in tools for working with an Association, developers also made many tools themselves as they modernized their code. Now many of those tools have found their way into the Wolfram Function Repository. Here I’ll highlight some of my favorites and show how they compare to built-in Wolfram Language functions.
Constructing
An Association stores key-value data. There are many Wolfram Language functions for creating an Association, including AssociationMap, AssociationThread, Counts and GroupBy. The Function Repository also includes several functions for creating new associations.
You can use Association directly on a list of rules to convert it, but it only works at the top level. ToAssociations converts lists of rules deep in the expression as well:
Engage with the code in this post by downloading the Wolfram Notebook
✕
Association@{"Beatles" -> {"Drums" -> "Ringo", "Guitar" -> "George"}} |
✕
ResourceFunction[ ResourceObject[ Association[ "Name" -> "ToAssociations", "ShortName" -> "ToAssociations", "UUID" -> "03f9ac8a-b9ca-4ed3-8f4e-6476f054192d", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Recursively replace lists of rules with \ associations", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$\ 54fdf8dcd89543ffb46a3ea9b1182424`ToAssociations", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/objects/1ece3c97-188a-4956-8d38-\ 22b164389275"]], ResourceSystemBase -> Automatic]]@{"Beatles" -> {"Drums" -> "Ringo", "Guitar" -> "George"}} |
AssociationMap creates an Association by mapping a single function over a list, using elements of the list as keys and the outputs as values. AssociationThrough does the opposite. It maps several functions over a single value:
✕
AssociationMap[Sqrt, {1, 4, 9, 16}] |
✕
ResourceFunction[ ResourceObject[ Association[ "Name" -> "AssociationThrough", "ShortName" -> "AssociationThrough", "UUID" -> "74d9311e-aa45-4f03-a0d5-72d677dd4d37", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Generate an Association from applying different \ operations to an expression", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$\ 3edb581b6fa745baace2a4c91f202de7`AssociationThrough", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/obj/21f685d1-26ec-4335-b378-\ f4524169c849"]], { ResourceSystemBase -> "https://www.wolframcloud.com/objects/\ resourcesystem/api/1.0"}]][{Sqrt, FactorInteger, Exp}, 16] |
SparseArray is an efficient way to store sparse numeric arrays. The values are indexed numerically. SparseAssociation generalized that concept to Association so that values are indexed with keys:
✕
rareanimalsightings = ResourceFunction[ ResourceObject[ Association[ "Name" -> "SparseAssociation", "ShortName" -> "SparseAssociation", "UUID" -> "8fabea7a-e08a-4e94-96b5-b1b7f580aa8d", "ResourceType" -> "Function", "Version" -> "3.0.0", "Description" -> "Create a rectangular data structure that \ behaves like a SparseArray indexed by string keys", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$\ 94720eb656ac4ab988411292dd6c42be`SparseAssociation", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/obj/d0ae185d-771e-48ba-a8d8-\ a0206b100607"]], ResourceSystemBase -> Automatic]][{{"April", "Black Bear"} -> 1, {"July", "Bald Eagle"} -> 4, {"August", "Bald Eagle"} -> 1, {"November", "Moose"} -> 1}, Automatic] |
It works like an Association:
✕
rareanimalsightings["April"]["Black Bear"] |
And it gives zero as the value for keys that were not explicitly given:
✕
rareanimalsightings["July"]["Black Bear"] |
Because those values are not stored in the SparseAssociation, it is smaller when there are many default values:
✕
sparseAssoc = ResourceFunction[ ResourceObject[ Association[ "Name" -> "SparseAssociation", "ShortName" -> "SparseAssociation", "UUID" -> "8fabea7a-e08a-4e94-96b5-b1b7f580aa8d", "ResourceType" -> "Function", "Version" -> "3.0.0", "Description" -> "Create a rectangular data structure that \ behaves like a SparseArray indexed by string keys", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$\ 94720eb656ac4ab988411292dd6c42be`SparseAssociation", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/obj/d0ae185d-771e-48ba-a8d8-\ a0206b100607"]], ResourceSystemBase -> Automatic]][ RandomInteger[1, {100, 200}], {Range[100], Range[200]}, 0] |
✕
ByteCount[sparseAssoc] |
✕
ByteCount@Normal[sparseAssoc] |
Modifying Associations
Associations can be modified using many standard Wolfram Language symbols like Map, KeyMap, MapAt and Set. However, the number of functions that data scientists want for manipulating their data is infinite, so they have created some of their own. Here are some that have been published in the Function Repository.
While MapAt can apply a single function to the values of specific keys in an Association, MapAtKey can apply different functions to different keys:
✕
MapAt[CubeRoot, <|"Odds" -> {-27, -8, -1}, "Evens" -> {16, 9, 4}|>, "Odds"] |
✕
ResourceFunction[ ResourceObject[ Association[ "Name" -> "MapAtKey", "ShortName" -> "MapAtKey", "UUID" -> "3d4313c6-a2fc-43b3-8eae-a8c8710a63c6", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Apply functions to specific keys in an \ association", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$\ 5312b39560ba48f6a984bd7c8146f70f`MapAtKey"], ResourceSystemBase -> Automatic]][{"Odds" -> CubeRoot, "Evens" -> Sqrt}, <|"Odds" -> {-27, -8, -1}, "Evens" -> {16, 9, 4}|>] |
KeyCombine is a combination of Merge and KeyMap that allows you to combine elements of an Association based on their keys:
✕
data = <|Entity["City", {"Chicago", "Illinois", "UnitedStates"}] -> "Windy City", Entity["City", {"LosAngeles", "California", "UnitedStates"}] -> "City of Angels", Entity["City", {"NewOrleans", "Louisiana", "UnitedStates"}] -> "The Big Easy"|>; |
Using KeyMap causes values to be lost:
✕
KeyMap[#["TimeZone"] &, data] |
KeyCombine preserves all values in a list:
✕
ResourceFunction[ ResourceObject[ Association[ "Name" -> "KeyCombine", "ShortName" -> "KeyCombine", "UUID" -> "fa2c6e6e-8664-409b-bfc5-a93c29fc6b01", "ResourceType" -> "Function", "Version" -> "2.0.0", "Description" -> "Map a function over the keys of an association, \ and collect or combine values in the event of key collisions", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$\ bea3f5ae2c744deba53ef74f53c8aab4`KeyCombine", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/obj/6e1d9eef-04c3-4671-a333-\ 0a7d7fbf10e2"]], ResourceSystemBase -> Automatic]][#[ "TimeZone"] &, data] |
Manually editing the content of an Association in a notebook can be challenging. AssociationEditor provides a convenient GUI form for editing content. I modified Bob’s value in the following example and used the print button to print out the updated Association:
<|Rick → 159,Paco → 90,Bob → 91,Michael → 74|>
✕
ResourceFunction[ ResourceObject[ Association[ "Name" -> "AssociationEditor", "ShortName" -> "AssociationEditor", "UUID" -> "4608276a-cfbc-4224-9c37-66c678f4c9b7", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Create an interface for editing an association", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$\ d9159c68ab564c33b8cad1ec86343ee7`AssociationEditor", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/obj/fce36585-c7cc-4b1e-9db6-\ 27851f5da755"]], ResourceSystemBase -> Automatic]][<|"Rick" -> 159, "Paco" -> 90, "Bob" -> 90, "Michael" -> 74|>] |
Nested Associations
In an Association, the keys can be any expression, including lists. A side effect of that feature is that a list usually cannot be used to specify a location deep inside a nested Association. Several Function Repository functions have been published specifically to help work with nested associations.
NestedLookup treats lists as an index deep within nested associations:
✕
ResourceFunction[ ResourceObject[ Association[ "Name" -> "NestedLookup", "ShortName" -> "NestedLookup", "UUID" -> "019287c7-c661-4b15-9eda-8a21b26f628e", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Look up a set of keys in order to get deeper \ parts of an association or list of rules", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$\ b791da76177d4107869cb5c5f6d20bf3`NestedLookup", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/objects/a3fc4cdf-12b6-48a5-b385-\ 12e52c08a9bb"]], { ResourceSystemBase -> "https://www.wolframcloud.com/objects/\ resourcesystem/api/1.0"}]][<| "Bob" -> <|"Age" -> 37, "Location" -> <| "City" -> Entity["City", {"SaintLouis", "Missouri", "UnitedStates"}], "Country" -> Entity["Country", "UnitedStates"]|>|>|>, {"Bob", "Location", "City"}] |
It also handles missing values at any level:
✕
ResourceFunction[ ResourceObject[ Association[ "Name" -> "NestedLookup", "ShortName" -> "NestedLookup", "UUID" -> "019287c7-c661-4b15-9eda-8a21b26f628e", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Look up a set of keys in order to get deeper \ parts of an association or list of rules", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$\ b791da76177d4107869cb5c5f6d20bf3`NestedLookup", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/objects/a3fc4cdf-12b6-48a5-b385-\ 12e52c08a9bb"]], { ResourceSystemBase -> "https://www.wolframcloud.com/objects/\ resourcesystem/api/1.0"}]][<| "Bob" -> <|"Age" -> 37, "Location" -> <| "City" -> Entity["City", {"SaintLouis", "Missouri", "UnitedStates"}], "Country" -> Entity["Country", "UnitedStates"]|>|>|>, {"Bob", "Weight"}, Missing["None of your business"]] |
NestedAssociate adds or modifies values deep in a nested Association:
✕
ResourceFunction[ ResourceObject[ Association[ "Name" -> "NestedAssociate", "ShortName" -> "NestedAssociate", "UUID" -> "6a1de66c-29c0-4b4b-974f-3f0965226b28", "ResourceType" -> "Function", "Version" -> "2.0.0", "Description" -> "Append a value in a nested association", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$\ 8b08653e8b74432c8eee479657b1ef74`NestedAssociate"], ResourceSystemBase -> Automatic]][<| "Bob" -> <|"Age" -> 37, "Location" -> <| "City" -> Entity["City", {"SaintLouis", "Missouri", "UnitedStates"}], "Country" -> Entity["Country", "UnitedStates"]|>|>|>, {"Bob", "Location", "State"} -> Entity["AdministrativeDivision", {"Missouri", "UnitedStates"}]] |
NestedKeyDrop removes key-value pairs from deep in a nested Association:
✕
ResourceFunction[ ResourceObject[ Association[ "Name" -> "NestedKeyDrop", "ShortName" -> "NestedKeyDrop", "UUID" -> "65d1bf41-d055-4dbd-8457-229f6311aaab", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Drop keys from a nested association", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$\ 68a694fc94ad4536ba33b2c7a060bc10`NestedKeyDrop", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/obj/1f3bd348-cf0e-4623-83d2-\ 8c85e205ed72"]], ResourceSystemBase -> Automatic]][<| "Bob" -> <|"Age" -> 37, "Location" -> <| "City" -> Entity["City", {"SaintLouis", "Missouri", "UnitedStates"}], "Country" -> Entity["Country", "UnitedStates"]|>|>|>, {"Bob", "Location", "City"}] |
AssociationMapAt maps a function deep in a nested Association:
✕
ResourceFunction[ ResourceObject[ Association[ "Name" -> "AssociationMapAt", "ShortName" -> "AssociationMapAt", "UUID" -> "2e4ee50f-119f-4b90-94fe-393d7002b2ff", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Similar to MapAt but with improved behavior for \ nested expressions involving associations", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$\ 952568bb39894a2f84b64a8049911e4b`AssociationMapAt", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/objects/a540b935-fc88-45de-92d8-\ 1c0442dc8e0f"]], { ResourceSystemBase -> "https://www.wolframcloud.com/objects/\ resourcesystem/api/1.0"}]][ GeoGraphics[#["Polygon"]] &, <| "Bob" -> <|"Age" -> 37, "Location" -> <| "City" -> Entity["City", {"SaintLouis", "Missouri", "UnitedStates"}], "Country" -> Entity["Country", "UnitedStates"]|>|>|>, {"Bob", "Location", "City"}] |
AssociationKeyFlatten converts a nested Association into a flat Association:
✕
ResourceFunction[ ResourceObject[ Association[ "Name" -> "AssociationKeyFlatten", "ShortName" -> "AssociationKeyFlatten", "UUID" -> "69db3426-da6c-4ea6-bfd6-d6700a604003", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Flatten keys in a nested association", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$\ 8c05022518a04e25b4f1cbf5ee92b720`AssociationKeyFlatten", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/obj/b22f7493-2be4-49ad-aba5-\ 580014219fd6"]], ResourceSystemBase -> Automatic]][<| "Bob" -> <|"Age" -> 37, "Location" -> <| "City" -> Entity["City", {"SaintLouis", "Missouri", "UnitedStates"}], "Country" -> Entity["Country", "UnitedStates"]|>|>|>] |
AssociationKeyDeflatten does the opposite operation*. It creates a nested association from a flat Association with lists as keys:
✕
ResourceFunction[ ResourceObject[ Association[ "Name" -> "AssociationKeyDeflatten", "ShortName" -> "AssociationKeyDeflatten", "UUID" -> "e8662614-c2e7-483a-ad65-d44c35c9224e", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Deflatten the keys in a flat association to \ create a nested association", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$\ a5b096a82d754179aaf6b245897ad2fa`AssociationKeyDeflatten", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/obj/12ecac2e-7661-4c9c-a757-\ 3cb216139675"]], ResourceSystemBase -> Automatic]][<|{"Bob", "Age"} -> 37, {"Bob", "Location", "City"} -> Entity["City", {"SaintLouis", "Missouri", "UnitedStates"}], {"Bob", "Location", "Country"} -> Entity["Country", "UnitedStates"]|>] |
* We thought the opposite of “flatten” might be “sharpen,” but we are reserving the name AssociationSharpen for this extreme data science function deployed as a resource function in my cloud account.
Modernization
The function Counts can be thought of as a modernization of the older function Tally:
✕
Tally[{1, 2, 3, 4, 1, 2, 3, 1, 2, 1}] |
✕
Counts[{1, 2, 3, 4, 1, 2, 3, 1, 2, 1}] |
Similarly, other functions that predate Association have been modernized in the Function Repository. Now there are two ways to Reap what you Sow:
✕
Reap[Sow[Entity["Plant", "Genus:Triticum"], "Seeds"]; "Fuel the tractor"; Sow[Entity["Plant", "Subspecies:ZeaMaysMays"], "Seeds"]; Sow["Division", "Politics"]; "Sleep"] |
✕
ResourceFunction[ ResourceObject[ Association[ "Name" -> "ReapAssociation", "ShortName" -> "ReapAssociation", "UUID" -> "08e5881e-0108-4ef1-90cf-93dd4d728d83", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Equivalent to Reap, but returns an association \ with tags as keys", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$\ 87a55fcacca942fe970284092367e935`ReapAssociation", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/objects/4e3143fa-44f9-43ff-b2d9-\ 51dab22866cc"]], { ResourceSystemBase -> "https://www.wolframcloud.com/objects/\ resourcesystem/api/1.0"}]][ Sow[Entity["Plant", "Genus:Triticum"], "Seeds"]; "Fuel the tractor"; Sow[Entity["Plant", "Subspecies:ZeaMaysMays"], "Seeds"]; Sow["Division", "Politics"]; "Sleep"] |
BinCounts splits data into bins and gives you the number of items in each bin, but does not return the actual bins. BinCountAssociation uses the keys of an Association to include that information in the results:
✕
BinCounts[{1, 3, 2, 1, 4, 5, 6, 2}, {0, 10, 1}] |
✕
ResourceFunction[ ResourceObject[ Association[ "Name" -> "BinCountAssociation", "ShortName" -> "BinCountAssociation", "UUID" -> "93ebf3eb-c8dc-4f6c-9ccc-5ed634837a30", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Collect histogram data in an association of bin \ intervals and bin heights", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$\ 450898eb8b12430c81d5d949562839b5`BinCountAssociation", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/obj/420c0f34-f35c-4544-8786-\ 6e52e7bb2341"]], ResourceSystemBase -> Automatic]][{1, 3, 2, 1, 4, 5, 6, 2}, {0, 10, 1}] |
Interoperability
A final, important aspect of the Wolfram Language and the Wolfram Function Repository is that there is consistency and interoperability among all the functions. Using a function created by one developer in the Function Repository does not mean that you have to build converters or translators to use other functions in the repository or in the Wolfram Language. To illustrate, here is a big pointless blob of Association-based operations using most of the functions discussed previously (and more) together seamlessly. While the result is meaningless, the immediate compatibility warms the heart:
✕
ResourceFunction[ ResourceObject[ Association[ "Name" -> "AssociationEditor", "ShortName" -> "AssociationEditor", "UUID" -> "4608276a-cfbc-4224-9c37-66c678f4c9b7", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Create an interface for editing an association", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$\ d9159c68ab564c33b8cad1ec86343ee7`AssociationEditor", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/obj/fce36585-c7cc-4b1e-9db6-\ 27851f5da755"]], ResourceSystemBase -> Automatic]]@ResourceFunction[ ResourceObject[ Association[ "Name" -> "KeySortLike", "ShortName" -> "KeySortLike", "UUID" -> "c9294236-189a-43da-a5e2-f91b5d125305", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Sort keys of an association in the same order \ as another set of keys", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$\ 12428d2999ba4e64a7c7c3aa13b84c65`KeySortLike", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/obj/f46b38d4-5ff1-428d-8349-\ 197555def917"]], { ResourceSystemBase -> "https://www.wolframcloud.com/objects/\ resourcesystem/api/1.0"}]][ResourceFunction[ ResourceObject[ Association[ "Name" -> "AssociationKeyFlatten", "ShortName" -> "AssociationKeyFlatten", "UUID" -> "69db3426-da6c-4ea6-bfd6-d6700a604003", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Flatten keys in a nested association", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$\ 8c05022518a04e25b4f1cbf5ee92b720`AssociationKeyFlatten", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/obj/b22f7493-2be4-49ad-aba5-\ 580014219fd6"]], ResourceSystemBase -> Automatic]]@ResourceFunction[ ResourceObject[ Association[ "Name" -> "AssociationMapAt", "ShortName" -> "AssociationMapAt", "UUID" -> "2e4ee50f-119f-4b90-94fe-393d7002b2ff", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Similar to MapAt but with improved behavior \ for nested expressions involving associations", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"]\ , "SymbolName" -> "FunctionRepository`$\ 952568bb39894a2f84b64a8049911e4b`AssociationMapAt", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/objects/a540b935-fc88-45de-92d8-\ 1c0442dc8e0f"]], ResourceSystemBase -> Automatic]][ResourceFunction[ ResourceObject[ Association[ "Name" -> "KeyCombine", "ShortName" -> "KeyCombine", "UUID" -> "fa2c6e6e-8664-409b-bfc5-a93c29fc6b01", "ResourceType" -> "Function", "Version" -> "2.0.0", "Description" -> "Map a function over the keys of an \ association, and collect or combine values in the event of key \ collisions", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.\ 0"], "SymbolName" -> "FunctionRepository`$\ bea3f5ae2c744deba53ef74f53c8aab4`KeyCombine", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/obj/6e1d9eef-04c3-4671-a333-\ 0a7d7fbf10e2"]], ResourceSystemBase -> Automatic]][Mod[#, 3] &, #] &, ResourceFunction[ ResourceObject[ Association[ "Name" -> "MapAtKey", "ShortName" -> "MapAtKey", "UUID" -> "3d4313c6-a2fc-43b3-8eae-a8c8710a63c6", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Apply functions to specific keys in an \ association", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.\ 0"], "SymbolName" -> "FunctionRepository`$\ 5312b39560ba48f6a984bd7c8146f70f`MapAtKey"], ResourceSystemBase -> Automatic]][{"Sown" -> ResourceFunction[ ResourceObject[ Association[ "Name" -> "ToAssociations", "ShortName" -> "ToAssociations", "UUID" -> "03f9ac8a-b9ca-4ed3-8f4e-6476f054192d", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Recursively replace lists of rules with \ associations", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.\ 0"], "SymbolName" -> "FunctionRepository`$\ 54fdf8dcd89543ffb46a3ea9b1182424`ToAssociations", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/objects/1ece3c97-188a-4956-\ 8d38-22b164389275"]], ResourceSystemBase -> Automatic]]}, ResourceFunction[ ResourceObject[ Association[ "Name" -> "ReapAssociation", "ShortName" -> "ReapAssociation", "UUID" -> "08e5881e-0108-4ef1-90cf-93dd4d728d83", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Equivalent to Reap, but returns an \ association with tags as keys", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/api/1.\ 0"], "SymbolName" -> "FunctionRepository`$\ 87a55fcacca942fe970284092367e935`ReapAssociation", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/objects/4e3143fa-44f9-43ff-\ b2d9-51dab22866cc"]], { ResourceSystemBase -> "https://www.wolframcloud.com/objects/\ resourcesystem/api/1.0"}]]@Table[Sow[i -> ResourceFunction[ ResourceObject[ Association[ "Name" -> "KeyCombine", "ShortName" -> "KeyCombine", "UUID" -> "fa2c6e6e-8664-409b-bfc5-a93c29fc6b01", "ResourceType" -> "Function", "Version" -> "2.0.0", "Description" -> "Map a function over the keys of an \ association, and collect or combine values in the event of key \ collisions", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/\ api/1.0"], "SymbolName" -> "FunctionRepository`$\ bea3f5ae2c744deba53ef74f53c8aab4`KeyCombine", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/obj/6e1d9eef-04c3-4671-\ a333-0a7d7fbf10e2"]], ResourceSystemBase -> Automatic]][ ResourceFunction[ ResourceObject[ Association[ "Name" -> "HashHue", "ShortName" -> "HashHue", "UUID" -> "9546ae91-2b23-4e84-8d3a-5e74a925ee04", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Map an expression to a color based on \ a hash", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/\ api/1.0"], "SymbolName" -> "FunctionRepository`$\ cfa180cfc14a404f9d8440f796bb8291`HashHue", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/obj/b4e7b1f1-8ab8-44a8-\ b209-18884124de2d"]], ResourceSystemBase -> Automatic]], ResourceFunction[ ResourceObject[ Association[ "Name" -> "BinCountAssociation", "ShortName" -> "BinCountAssociation", "UUID" -> "93ebf3eb-c8dc-4f6c-9ccc-5ed634837a30", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Collect histogram data in an \ association of bin intervals and bin heights", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/\ api/1.0"], "SymbolName" -> "FunctionRepository`$\ 450898eb8b12430c81d5d949562839b5`BinCountAssociation", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/obj/420c0f34-f35c-4544-\ 8786-6e52e7bb2341"]], ResourceSystemBase -> Automatic]][ Values@ResourceFunction[ ResourceObject[ Association[ "Name" -> "AssociationThrough", "ShortName" -> "AssociationThrough", "UUID" -> "74d9311e-aa45-4f03-a0d5-72d677dd4d37", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Generate an Association from \ applying different operations to an expression", "RepositoryLocation" -> URL[ "https://www.wolframcloud.com/objects/resourcesystem/\ api/1.0"], "SymbolName" -> "FunctionRepository`$\ 3edb581b6fa745baace2a4c91f202de7`AssociationThrough", "FunctionLocation" -> CloudObject[ "https://www.wolframcloud.com/obj/21f685d1-26ec-4335-\ b378-f4524169c849"]], { ResourceSystemBase -> "https://www.wolframcloud.com/\ objects/resourcesystem/api/1.0"}]][{Sqrt, Exp}, i]]], "Factors"], {i, 1, 40}]], {"Sown", "Factors"}], {{"Sown", "Factors", 1}, "Result"}] |
The functions mentioned here are only some of the Association tools in the Function Repository, which in turn are only a small piece of the consistently growing collection in the full repository. Every week, new functions are added that both expand the Wolfram Language and fill in some of its gaps. There is no longer any need to wait for Wolfram Language version releases to see the latest and greatest new functions: you can get them any time you want right here.
Explore more user contributions like the functions mentioned here or submit your own computational creations at the Wolfram Function Repository. |
Some functions should really be integrated!
MergeByKey is another one people might find useful. I made it because I found that Merge is often a bit limiting for complex datasets.
https://resources.wolframcloud.com/FunctionRepository/resources/MergeByKey