# ↑ ABC Example: A Telephone List

This uses the table data-type. In use, tables resemble arrays:
```        >>> PUT {} IN tel
>>> PUT 4054 IN tel["Jennifer"]
>>> PUT 4098 IN tel["Timo"]
>>> PUT 4134 IN tel["Guido"]

>>> WRITE tel["Jennifer"]
4054
```
You can write all ABC values out. Tables are kept sorted on the keys:
```        >>> WRITE tel
{["Guido"]: 4134; ["Jennifer"]: 4054; ["Timo"]: 4098}```
The keys function returns a list:
```        >>> WRITE keys tel
{"Guido"; "Jennifer"; "Timo"}

>>> FOR name IN keys tel:
WRITE name, ":", tel[name] /
Guido: 4134
Jennifer: 4054
Timo: 4098```
You can define your own commands:
```        HOW TO DISPLAY t:
FOR name IN keys t:
WRITE name0, t[name] /

>>> DISPLAY tel
Guido      4134
Jennifer   4054
Timo       4098```
To find the user of a given number, you can use a quantifier:
```        >>> IF SOME name IN keys tel HAS tel[name] = 4054:
WRITE name
Jennifer```
Or create the inverse table:
```        >>> PUT {} IN subscriber
>>> FOR name IN keys tel:
PUT name IN subscriber[tel[name]]

>>> WRITE subscriber[4054]
Jennifer

>>> WRITE subscriber
{[4054]: "Jennifer"; [4098]: "Timo"; [4134]: "Guido"}
```
Commands and functions are polymorphic:
```        >>> DISPLAY subscriber
4054       Jennifer
4098       Timo
4134       Guido```
Functions may return any type. Note that indentation is significant - there are no BEGIN-END's or { }'s:
```        HOW TO RETURN inverse t:
PUT {} IN inv
FOR k IN keys t:
PUT k IN inv[t[k]]
RETURN inv

>>> WRITE inverse tel
{[4054]: "Jennifer"; [4098]: "Timo"; [4134]: "Guido"}

>>> DISPLAY inverse inverse tel
Guido      4134
Jennifer   4054
Timo       4098
```