Continuing our Data-centric approach to learning Wolfram language we will tackle Associations aka Dictionaries.
When you are training Neural Networks the data is usually supplied as an association which is a mapping between keys and values. We will learn about Neural Networks much later but for now, let us see the kinds of things you can do with associations
We use the less than < sign with a bar | combined together on start the association. The content of the association are comma separated lists of key -> value pairs. We close it with a vertical bar and a greater than sign. As you can see below there is no intrinsic requirements that they keys or the values are of a special data type. They could be anything due to the symbolic nature of the Wolfram language. Below we map symbols to symbols.
You can build an association from a list of mappings
My favourite operation is performing SQL-like SELECT on an association. In principle you could build a full database using associations
The Select function above reads like: Select from association where value greater than 3. Note that is not the keys but the values we select even though the keys are also numerical. We do the selection using a pure function
1. Create an association mapping any two things of interest to you. 2. Perform all the operations we have covered in this session 3. Go the Wolfram Documentation, search for associations in the search bar, open the page and try to perform as many operations as you can on the association you created above. 4. How would you go about to create a database with Tables for storing data an mechanisms for retrieving the data? You are not expected to do this but it is a great thinking exercise.