> For the complete documentation index, see [llms.txt](https://docs.urbit.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.urbit.org/hoon/stdlib/2o.md).

# 2o: Normalizing Containers

Mold generators for common container types including maps, sets, queues, jars, and jugs.

## `+jar` <a href="#jar" id="jar"></a>

`$mold` generator. A `+jar` is a `+map` of `+list`.

Produces the `$mold` of a `+map` from `key` to lists of `value`.

#### Accepts

`$key` is a `$mold`, and is the type of the `+map` key.

`$value` is a `$mold`, and is the type of items in the lists. The lists are the values in the `+map`.

#### Produces

A `$mold`.

#### Source

```hoon
++  jar  |$  [key value]  (map key (list value))
```

#### Examples

```
> `(jar @t @ud)`(malt ~[['foo' ~[1 2 3]] ['bar' ~[4 5 6]]])
{[p='bar' q=~[4 5 6]] [p='foo' q=~[1 2 3]]}
```

#### Discussion

See also: [`+ja`](/hoon/stdlib/2j.md#ja), [`+by`](/hoon/stdlib/2i.md), [`+map`](#map), [`+list`](/hoon/stdlib/2b.md)s.

***

## `+jug` <a href="#jug" id="jug"></a>

`$mold` generator. Produces a `+jug`, which is a `(map key (set value))`.

#### Accepts

`$key` is a `$mold`, and is the type of the `+map` key.

`$value` is a `$mold`, and is the type of items in the `+set`s. The `+set`s are the values in the `+map`.

#### Produces

A `$mold`.

#### Source

```hoon
++  jug  |$  [key value]  (map key (set value))
```

#### Examples

```
> `(jug @t @ud)`(malt ~[['foo' (silt ~[1 2 3])] ['bar' (silt ~[4 5 6])]])
{[p='bar' q={5 6 4}] [p='foo' q={1 2 3}]}
```

#### Discussion

See also: [`+ju`](/hoon/stdlib/2j.md#ju), [`+by`](/hoon/stdlib/2i.md), [`+map`](#map), [`+set`](#set).

***

## `+map` <a href="#map" id="map"></a>

A `+map` is a [treap](https://en.wikipedia.org/wiki/Treap) of key-value pairs.

Produces the `$mold` of a `+map` from `key` to `value`.

#### Accepts

`$key` is a `$mold`.

`$value` is a `$mold`.

#### Produces

A `$mold`.

#### Source

```hoon
++  map
  |$  [key value]
  $|  (tree (pair key value))
  |=(a=(tree (pair)) ?:(=(~ a) & ~(apt by a)))
```

#### Examples

```
> ? *(map @t @ud)
  nlr([p=@t q=@ud])
{}
```

```
> `(map @t @ud)`(malt ~[['foo' 1] ['bar' 2] ['baz' 3]])
{[p='bar' q=2] [p='baz' q=3] [p='foo' q=1]}
```

#### Discussion

See also: [`+by`](/hoon/stdlib/2i.md).

***

## `+qeu` <a href="#qeu" id="qeu"></a>

Queue.

`$mold` generator. An ordered [treap](http://en.wikipedia.org/wiki/Treap) of items.

Produces the `$mold` of a queue of `$item`.

#### Accepts

`$item` is a `$mold`.

#### Produces

A `$mold`.

#### Source

```hoon
++  qeu
  |$  [item]
  $|  (tree item)
  |=(a=(tree) ?:(=(~ a) & ~(apt to a)))
```

#### Examples

```
> `(qeu @ud)`(~(gas to *(qeu @ud)) ~[1 2 3 4 5])
{5 4 3 2 1}
```

#### Discussion

See also: [`+to`](/hoon/stdlib/2k.md#to).

***

## `+set` <a href="#set" id="set"></a>

Set.

`$mold` generator. A `+set` is an unordered [treap](http://en.wikipedia.org/wiki/Treap) of items.

Produces the `$mold` of a `+set` of `$item`.

#### Accepts

`$item` is a `$mold`.

#### Produces

A `$mold`.

#### Source

```hoon
++  set
  |$  [item]
  $|  (tree item)
  |=(a=(tree) ?:(=(~ a) & ~(apt in a)))
```

#### Examples

```
> `(set @ud)`(silt ~[1 2 3 4 5])
{5 1 2 3 4}
```

#### Discussion

See also: [`+in`](/hoon/stdlib/2h.md).

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.urbit.org/hoon/stdlib/2o.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
