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
- In the case of AssociationMap[f,assoc], later instances of repeated keys replace earlier ones.
- 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 (2)
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:
Properties & Relations (1)
Compute AssociationMap in parallel:
Possible Issues (1)
AssociationMap[f,assoc] can return invalid associations if f does not return a rule:
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