# Associations

`Association → Object`

A simple mapping from one value to another.

```a == b → Boolean
| a is-a?: Association
| b is-a?: Association```

Perform a deep equality check.

Example:

```> (1 -> 2) == (1 -> 2)
True
> (1 -> \$2) == ("one" -> 2)
False
```
`a -> b → Association`

Create a new `Association` from `a` to `b`.

This operator is right-associative and has a very low precedence level:

Example:

```> 1 -> \$a
1 -> \$a
> True -> 10
True -> 10
> 1 -> (2 -> (3 + 4))
1 -> (2 -> 7)
```
```a from → any
| a is-a?: Association```

Yields `a`'s "from" value.

Example:

```> (1 -> \$a) from
1
```
```a to → any
| a is-a?: Association```

Yields `a`'s "to" value.

Example:

```> (1 -> \$a) to
\$a
```
```list lookup: from → in?: [@(ok: any), @none]
| list is-a?: List```

Looks up a key in a list of `Associations` by `from`, returning either the association's `to` value or `@none`.

Example:

```> [1 -> \$a, 2 -> \$b] lookup: 1
@(ok: \$a)
> [1 -> \$a, 2 -> \$b] lookup: 5
@none
```
```list find: from → in?: [@(ok: Association), @none]
| list is-a?: List```

Similar to `lookup:`, except it returns the `Association` object rather than its `to` value.

Example:

```> [1 -> \$a, 2 -> \$b] find: 1
@(ok: 1 -> \$a)
> [1 -> \$a, 2 -> \$b] find: 5
@none
```
```list set: key to: value → list
| list is-a?: List```

Sets an association from `key` to `value` in `list`, updating an association if it exists or adding it to the list if it doesn't.

Example:

```> [1 -> \$a, 2 -> \$b] set: 2 to: \$B
[1 -> \$a, 2 -> \$B]
> [1 -> \$a, 2 -> \$b] set: 3 to: \$c
[1 -> \$a, 2 -> \$b, 3 -> \$c]
```