Associations
Notes for Java programmers:
Wolfram Language Associations are similar to Java's Map or HashMap, but with more readable syntax and much more flexible usage.
Notes for Python programmers:
Associations in the Wolfram Language work similarly to Python dictionaries. Using an Association, programmers can associate keys to values with highly efficient lookup and updating, even with millions of elements, and they also preserve the order of element insertion without needing specialized data structures like Python's OrderedDict. When coding in Python with the Wolfram Client Library for Python, classes like dict, OrderedDict and Series (from the Pandas library) serialize to Association.
Associations associate keys and values:
(→ is typed using ->
)
(The keys in associations don't have to be strings, but often are.)
Applying an association to a key gives the corresponding value:
In a pure function, #
key picks out the value corresponding to "key" in an association:
You can mix associations and lists, and pick out parts using [[ ... ]]:
String templates work with associations (as do XML and notebook templates):
QUICK REFERENCE: Associations