AssociationMap
AssociationMap[f,{key1,key2,…}]
creates the association key1f[key1],key2f[key2],….
AssociationMap[f,key1val1,key2val2,…]
creates the association f[key1val1],f[key2val2],….
represents an operator form of AssociationMap that can be applied to an expression.
Details
- AssociationMap is typically used to apply a single common function to each of a list of arguments, creating an association of the corresponding values.
- If AssociationMap[f,…] produces repeated keys, later instances replace earlier ones. »
- If AssociationMap produces repeated keys, later instances replace earlier ones. »
- AssociationMap uses the keys as arguments to produce the values. AssociationComap uses the keys as heads. »
- AssociationMap[f][expr] is equivalent to AssociationMap[f,expr].
- Parallelize[AssociationMap[f,{key1,key2,…}]] computes AssociationMap[f,{key1,key2,…}] in parallel on all subkernels. »
Examples
open allclose allBasic Examples (3)
Create an association by mapping a function over a list of keys:
Create an "inverted index" by swapping keys and values:
Use the operator form of AssociationMap:
Scope (1)
Properties & Relations (6)
AssociationMap[f,{x1,x2,…}] creates an association with keys xi:
The values in the association are given by Map[f,{x1,x2,…}]:
AssociationMap[f,{x1,x2,…}] is equivalent to AssociationThread[{x1,x2,…}Map[f,{x1,x2,…}]]:
AssociationMap[f,list] gives an association with the same length as DeleteDuplicates[list]:
AssociationMap maps a function over the rules in an association:
KeyValueMap maps a function over the keys and values in an association (and returns a list):
KeyMap maps a function over the keys in an association:
Map maps a function over the values in an association:
AssociationMap wraps an expression around the keys in a list:
AssociationComap wraps the keys in a list around an expression:
AssociationMap can be parallelized automatically:
Possible Issues (1)
Text
Wolfram Research (2014), AssociationMap, Wolfram Language function, https://reference.wolfram.com/language/ref/AssociationMap.html.
CMS
Wolfram Language. 2014. "AssociationMap." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/AssociationMap.html.
APA
Wolfram Language. (2014). AssociationMap. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AssociationMap.html