on master help sign in
minor improvements to list tutorial
33785d2John Franklin
learn/hoon/hoon-tutorial/lists.md+10−3
@@ -54,7 +54,7 @@ find-fork-d
54~[2 3 4 5]
54~[2 3 4 5]
55```
55```
56
56
57−It's important to note that performing tests like `?~ mylist` will actually transform `mylist` in to a `lest`, a non-null list. Because `lest` is a different type than `list`, performing such tests can come back to bite you later in non-obvious ways when you try to use some standard library functions meant for `list`s.
57+It's important to note that performing tests like `?~ mylist` will actually transform `mylist` into a `lest`, a non-null list. Because `lest` is a different type than `list`, performing such tests can come back to bite you later in non-obvious ways when you try to use some standard library functions meant for `list`s.
58
58
59You can construct lists of any type. `(list @)` indicates a list of atoms, `(list ^)` indicates a list of cells, `(list [@ ?])` indicates a list of cells whose head is an atom and whose tail is a flag, etc.
59You can construct lists of any type. `(list @)` indicates a list of atoms, `(list ^)` indicates a list of cells, `(list [@ ?])` indicates a list of cells whose head is an atom and whose tail is a flag, etc.
60
60
@@ -94,9 +94,9 @@ You can also use the words `cord` and `tape` for casting:
94
94
95## List Functions in the Hoon Standard Library
95## List Functions in the Hoon Standard Library
96
96
97−Lists are a commonly used data structure. Accordingly, there are several functions in the [Hoon standard library](/docs/reference/library/2b/) intended to make lists easier to use.
97+Lists are a commonly used data structure. Accordingly, there are several functions in the [Hoon standard library](/docs/reference/library/) intended to make lists easier to use.
98
98
99−For a complete list of these functions, check out the standard library reference for lists here (link). Here we'll look at a few of these functions.
99+For a complete list of these functions, check out the standard library reference for lists [here](/docs/reference/library/2b/). Here we'll look at a few of these functions.
100
100
101### `flop`
101### `flop`
102
102
@@ -196,6 +196,13 @@ nest-fail
196
196
197The problem is that `snag` is expecting a raw list, not a list that is known to be non-null.
197The problem is that `snag` is expecting a raw list, not a list that is known to be non-null.
198
198
199+You can cast `b` to `(list)` to work around this:
200+
201+```
202+> ?~(b ~ (snag 0 `(list)`b))
203+11
204+```
205+
199#### `snag` exercise
206#### `snag` exercise
200
207
201Without using `snag`, write a gate that returns the `n`th item of a list. There is a solution at the bottom of this lesson.
208Without using `snag`, write a gate that returns the `n`th item of a list. There is a solution at the bottom of this lesson.