WLJS LogoWLJS Notebook

AssociationMap

AssociationMap[f, {key1, key2, ...}] creates the association <|key1 -> f[key1], key2 -> f[key2], ...|>.

AssociationMap[f, <|key1 -> val1, key2 -> val2, ...|>] creates <|f[key1 -> val1], f[key2 -> val2], ...|>.

Examples

Map a function to create values:

AssociationMap[StringLength, {"cat", "dog", "elephant"}]
(* <|"cat" -> 3, "dog" -> 3, "elephant" -> 8|> *)

Transform key-value pairs:

AssociationMap[Reverse, <|a -> 1, b -> 2|>]
(* <|1 -> a, 2 -> b|> *)

Please visit the official Wolfram Language Reference for more details.

On this page