# 2m: Container from Noun

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

A `+list` from raw `$noun`.

Takes a null-terminated `$noun` and produces a `+list`.

#### Accepts

`.a` is a null-terminated `$noun`.

#### Produces

A `+list`.

#### Source

```hoon
++  ly
  le:nl
```

#### Examples

```
> (ly [1 2 3 ~])
~[1 2 3]
```

```
> (ly "abc")
~['a' 'b' 'c']
```

#### Discussion

`+ly` is an alias for `+le:nl`.

***

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

Map from raw `$noun`.

Takes a null-terminated `$noun` and produces a `+map`.

#### Accepts

`.a` is a `$noun` composed of ordered pairs and terminated with `~`.

#### Produces

A `+map`.

#### Source

```hoon
++  my
  my:nl
```

#### Examples

```
> (my [['a' 1] ['b' 2] ~])
[n=[p='b' q=2] l={[p='a' q=1]} r={}]
```

#### Discussion

Note that `+my` is an alias for `+my:nl`.

***

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

Set from raw `$noun`.

Takes a null-terminated `$noun` and produces a `+set`.

#### Accepts

`.a` is a null-terminated `$noun`.

#### Produces

A `+set`.

#### Source

```hoon
++  sy
  si:nl
```

#### Examples

```
> (sy [1 2 3 ~])
[n=2 l={1 3} r={}]
```

```
> (sy (ly [1 2 3 ~]))
[n=2 l={1 3} r={}]
```

```
> (sy "abc")
[n='b' l={'a' 'c'} r={}]
```

#### Discussion

`+sy` is an alias for `+si:nl`.

***

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

Noun-to-container operations.

Core whose arms contain functions that create various typed `$noun`s from raw `$noun`s.

#### Source

```hoon
++  nl
  |%
```

***

### `+le:nl` <a href="#lenl" id="lenl"></a>

Construct `+list`.

Takes a null-terminated `$noun` and produces a `+list`.

#### Accepts

`.a` is a null-terminated `$noun`.

#### Produces

A `+list`.

#### Source

```hoon
++  le
  |*  a=(list)
  ^+  =<  $
    |@  ++  $  ?:(*? ~ [i=(snag 0 a) t=$])
    --
  a
```

#### Examples

```
> (le:nl [1 2 3 ~])
~[1 2 3]
```

```
> (le:nl "abc")
~['a' 'b' 'c']
```

***

### `+my:nl` <a href="#mynl" id="mynl"></a>

Construct `+map`.

Takes a null-terminated `$noun` and produces a `+map` of the same type of the `.p` and `.q` passed in.

#### Accepts

`.a` is a `$noun` composed of ordered pairs and terminated with `~`.

#### Produces

A `+map`.

#### Source

```hoon
++  my
  |*  a=(list (pair))
  =>  .(a ^+((le a) a))
  (~(gas by `(map _p.i.-.a _q.i.-.a)`~) a)
```

#### Examples

```
> (my:nl [['a' 1] ['b' 2] ~])
[n=[p='b' q=2] l={[p='a' q=1]} r={}]
```

***

### `+si:nl` <a href="#sinl" id="sinl"></a>

Construct `+set`.

Takes a null-terminated `$noun` and produces a `+set`.

#### Accepts

`.a` is a null-terminated `$noun`.

#### Produces

A `+set`.

#### Source

```hoon
++  si
  |*  a=(list)
  =>  .(a ^+((le a) a))
  (~(gas in `(set _i.-.a)`~) a)
```

#### Examples

```
> (si:nl `(list [@t *])`[['a' 1] ['b' [2 3]] ~])
[n=['b' [2 3]] l={['a' 1]} r={}]
```

***

### `+snag:nl` <a href="#snagnl" id="snagnl"></a>

Index.

Produces the element at the index `.a` of null-terminated `$noun` `.b` and failing if the `$noun` is null. `+list`s are 0-indexed.

#### Accepts

`.a` is a `$noun`.

`.b` is a null-terminated `$noun`.

#### Produces

A `$noun`.

#### Sources

```hoon
++  snag
  |*  [a=@ b=(list)]
  ?~  b
    ~_  leaf+"snag-fail"
    !!
  ?:  =(0 a)  i.b
  $(b t.b, a (dec a))
```

#### Examples

```
> =b [[2 3] [1 4] ~]

> (snag:nl 0 b)
[2 3]

> (snag:nl 2 b)
! snag-fail
! exit
```

***

### `+weld:nl` <a href="#weldnl" id="weldnl"></a>

Concatenate.

Produces a `+list` that is the concatenation of null-terminated `$noun`s `.a` and `.b`.

#### Accepts

`.a` is a null-terminated `$noun`.

`.b` is a null-terminated `$noun`.

#### Produces

A `+list`.

#### Source

```hoon
++  weld
  |*  [a=(list) b=(list)]
  =>  .(a ^+((le a) a), b ^+((le b) b))
  =+  42
  |-
  ?~  a  b
  [i=i.a t=$(a t.a)]
```

#### Examples

```
> =b [[2 3] [1 4] ~]

> (weld:nl b [8 9 ~])
[i=[2 3] t=[i=[1 4] t=~[8 9]]]
```

***
