@@ -11,7 +11,7 @@ Hoon isn't an object-oriented programming language; it's a "subject-oriented" pr
1111
1212For now we can say three things about the subject: (1) every Hoon expression is evaluated relative to some subject; (2) roughly, the subject defines the environment in which a Hoon expression is evaluated; and (3) the subject is a noun.
1313
14−In fact, you already created some subjects in lesson 1.2 when you used `+` to return a fragment of a noun:
14+In fact, you already learned about the noun address system in [Lesson 1.2](../nouns.md) when you used `+` to return a fragment of a noun:
1515
1616```
1717> +1:[[11 22] 33]
@@ -58,7 +58,7 @@ Let's create a subject with some computations:
5858
5959## Limbs of the Subject
6060
61−The subject is a noun, just like any other piece of Hoon data. In the last lesson we discussed how any noun can be understood as a binary tree. E.g., `[[4 5] [6 [14 15]]]`:
61+The subject is a noun, just like any other piece of Hoon data. In Lesson 1.2 we discussed how any noun can be understood as a binary tree. E.g., `[[4 5] [6 [14 15]]]`:
6262
6363```
6464 [[4 5] [6 [14 15]]]
@@ -79,7 +79,7 @@ Sometimes a programmer simply wants to produce a value from the subject. In oth
7979
8080### Address-based Limb Expressions
8181
82−A limb expression is an expression of Hoon that resolves to a limb of the subject. An address-based limb expression evaluates to a limb of the subject based on its noun address. (You learned about the noun address system in the last lesson.)
82+A limb expression is an expression of Hoon that resolves to a limb of the subject. An address-based limb expression evaluates to a limb of the subject based on its noun address.
8383
8484In the following you'll learn the various limb expressions available in Hoon, as well as how they work when they resolve to legs. First we'll explain the limb expressions that return a leg according to subject address.
8585
@@ -176,6 +176,27 @@ You can think of this sort of lark series -- e.g., `+>-<` -- as indicating a bin
176176 *Head* Tail
177177```
178178
179+#### Exercise 1.6a
180+1. Use a lark expression to obtain the value 6 in the following noun represented by a binary tree:
181+```
182+ .
183+ /\
184+ / \
185+ / \
186+ . .
187+ / \ / \
188+ / . 10 .
189+ / / \ / \
190+ . 8 9 11 .
191+ / \ / \
192+5 . 12 13
193+ / \
194+ 6 7
195+```
196+2. Use a lark expression to obtain the value 9 in the following noun: `[[5 6] 7 [[8 9 10] 3] 2] 1]`.
197+
198+Solutions to these exercises may be found at the bottom of this lesson.
199+
179200#### `&` and `|` operators
180201
181202`&n` returns the `n`th item of a list that has at least `n + 1` items. `|n` returns everything after `&n`.
@@ -223,9 +244,9 @@ The list items can themselves be cells:
223244['third' %pair]
224245```
225246
226−We can give an alternate, recursive definition of `&n` for all positive integers `n`. In the base case, `&1` is equivalent to `+2`. For the generating case, assume that `&(n - 1)` is equivalent to `+k`. Then `&n` is equivalent to `+((k x 2) + 2)`.
247+We can give an alternate, recursive definition of `&n` for all positive integers `n`. In the base case, `&1` is equivalent to `+2`. For the generating case, assume that `&(n - 1)` is equivalent to `+k`. Then `&n` is equivalent to `+((k × 2) + 2)`.
227248
228−For example, let `n` be 4. What is `&4`? `&3` is equivalent to `+14`. `(14 x 2) + 2` is `30`, so `&4` is equivalent to `+30`.
249+For example, let `n` be 4. What is `&4`? `&3` is equivalent to `+14`. `(14 × 2) + 2` is `30`, so `&4` is equivalent to `+30`.
229250
230251`|n` returns the rest of the list after `&n`:
231252
@@ -243,7 +264,7 @@ For example, let `n` be 4. What is `&4`? `&3` is equivalent to `+14`. `(14 x
243264~
244265```
245266
246−As with `&n`, we can characterize `|n` recursively. In the base case, `|1` is `+3`. In the generating case, assume that `|(n - 1)` is equivalent to `+k`. Then `|n` is equivalent to `+((k x 2) + 1)`.
267+As with `&n`, we can characterize `|n` recursively. In the base case, `|1` is `+3`. In the generating case, assume that `|(n - 1)` is equivalent to `+k`. Then `|n` is equivalent to `+((k × 2) + 1)`.
247268
248269### Other Limb Expressions: Names
249270
@@ -654,3 +675,52 @@ You can also use more complex wings and modify their values as well:
654675
655676At this point you should have at least a rough idea of what the subject is, and a fair understanding of how to get legs of the subject using wings. But legs are only one kind of limb -- we'll talk about arms in the next lesson.
656677
678+#### Exercise 1.6b
679+Enter the following into dojo:
680+```
681+=a [[[b=%bweh a=%.y c=8] b="no" c="false"] 9]
682+```
683+Test your knowledge from this lesson by evaluating the following expressions and then checking your answer in the dojo or see the solutions below.
684+
685+1. `> b:a(a [b=%skrt a="four"])`
686+2. `> ^b:a(a [b=%skrt a="four"])`
687+3. `> ^^b:a(a [b=%skrt a="four"])`
688+4. `> b.a:a(a [b=%skrt a="four"])`
689+5. `> a.a:a(a [b=%skrt a="four"])`
690+6. `+.a:a(a [b=%skrt a="four"])`
691+7. `a:+.a:a(a [b=%skrt a="four"])`
692+8. `a(a a)`
693+9. `b:-<.a(a a)`
694+10. How many times does the atom `9` appear in `a(a a(a a))`?
695+
696+## Exercise Solutions
697+
698+### Exercise 1.6a
699+1.
700+```
701+> =b [[[5 6 7] 8 9] 10 11 12 13]
702+> ->-:b
703+8
704+```
705+2.
706+```
707+> =c [[5 6] 7 [[8 9 10] 3] 2]
708+> +>-<+<:c
709+9
710+```
711+
712+### Exercise 1.6b
713+1. `%bweh`
714+2. `"no"`
715+3. Error: `ford: %slim failed:`
716+4. `%skrt`
717+5. `"four"`
718+6. `a="four"` - Note that this is different from the above!
719+7. `"four"`
720+8. `[[[b=%bweh a=[[[b=%bweh a=%.y c=8] b="no" c="false"] 9] c=8] b="no" c="false"]9]`
721+9. `%bweh`
722+10. `9` appears 3 times:
723+```
724+> a(a a(a a))
725+[[[ b=%bweh a [[[b=%bweh a=[[[b=%bweh a=%.y c=8] b="no" c="false"] 9] c=8] b="no" c="false"] 9] c=8] b="no" c="false"] 9]
726+```