# Lists & Maps | EasyNet Docs Source: https://easynet.run/docs/aal/collections # Lists & Maps Store multiple values and look them up by key. List stores elements of one type; Map associates keys with values. Here we count labels and write the result into a map. ## Complete example Save the example as collections.aal collections.aal ``` agent Tutorial is Agent public ability run() -> Int effects() labels = ["docs", "tools"] labels.append("agents") counts = Map{"total": 0} counts["total"] = labels.len() return counts["total"] ``` [Download .aal](data:text/plain;charset=utf-8,agent%20Tutorial%20is%20Agent%0A%20%20public%0A%20%20%20%20ability%20run()%20-%3E%20Int%20effects()%0A%20%20%20%20%20%20labels%20%3D%20%5B%22docs%22%2C%20%22tools%22%5D%0A%20%20%20%20%20%20labels.append(%22agents%22)%0A%20%20%20%20%20%20counts%20%3D%20Map%3CString%2CInt%3E%7B%22total%22%3A%200%7D%0A%20%20%20%20%20%20counts%5B%22total%22%5D%20%3D%20labels.len()%0A%20%20%20%20%20%20return%20counts%5B%22total%22%5D%0A) ## Syntax explained Write a list as ["docs", "tools"]. Access with items[0] and add with .append(value). An explicit map is Map{"total": 0}; read or write using map["total"]. Lists and records have value semantics: assignment and calls clone owned values. Local collection mutation does not require memory.write. ## Build and run Terminal ``` cargo run --locked --bin aalc -- check collections.aal cargo run --locked --bin aalc -- build collections.aal -o collections.aalc cargo run --locked --bin aalc -- run collections.aalc \ --agent Tutorial --ability run \ --args '{}' \ --state-dir .aal-tutorial/collections --invocation collections-1 ``` Run with a fresh state directory. The returned value is shown below; the CLI also prints execution information. Expected result ``` 3 ``` ## Try it yourself Add labels.append("notes"), rebuild and use a new invocation ID. The returned count should change from 3 to 4. [Language source and specification](https://github.com/Brain-Cell-Coding/Agent-Assembly-Language/blob/main/docs/ordered-maps.md)