@@ -32,8 +32,14 @@ Can you understand this code by just looking at it? Maybe.
3232But let's explain it anyway.
3333
3434Hoon is a functional language. FizzBuzz is usually defined as a
35−side effect, but Hoon has no side effects. This code will
36−*make* a list of strings, not *print* a list of strings.
35+side effect, but officially Hoon has no side effects. This code
36+will *return* a list of strings, not *print* a list of strings.
37+(Of course, if you run this code from the Urbit `dojo` (shell) you
38+will be able to see the product.)
39+
40+The code produces a list in which each item is either a number
41+(as a string), "Fizz", "Buzz", or "Fizzbuzz". The value `~` is
42+"null" and indicates the end of the list.
3743
3844Line 1 defines a function of one argument, `end`, an unsigned
3945integer.
@@ -42,22 +48,28 @@ Line 2 declares a variable, `count`, with initial value `1`.
4248
4349Line 3 begins a loop.
4450
45−Line 4 casts the product of the loop to a list of `tape`
46−(string as a character list).
51+Line 4 defines the product of the loop as a list of `tape`s.
52+(A `tape` is a list of characters, one of Hoon's two string
53+types.)
4754
4855Line 5 checks if `count` equals `end`. If so, line 6 (and the
49−whole loop) produces the value `~`, null, the empty list. If
50−not, line 7 begins an ordered pair.
56+whole loop) returns the value `~`. If not, line 7 produces an
57+ordered pair. (This pair will be: (a) the next item in the list,
58+and (b) the rest of the list.)
5159
52−The head of the pair is "FizzBuzz", or "Fizz", or "Buzz", if the
53−respective tests hit. If not, line 14 wraps a runtime type
54−around `count`, then prints the type-value pair to a string (like
55−C `sprintf()`). This string is the first item in the output list.
60+(a) The head of the pair is: (i) "FizzBuzz", or "Fizz", or
61+"Buzz", if the respective tests hit; otherwise, it's
62+(ii) the number in question, `count`. In case (ii), line 14
63+makes `count` into a `tape`, first by using `:wrap` to produce a
64+pair: runtime type of `count`, and `count` itself. `pave` is a
65+Hoon function that converts the type-value pair to a `tape`
66+(like C `sprintf()`).
5667
57−The tail of the pair is line 15, which repeats the loop (like
58−Clojure `recur`), with `count` incremented. This list of strings
59−is the rest of the output list.
68+(b) The tail of the pair—the rest of the output list—is
69+produced at line 15, which repeats the loop (like Clojure
70+`recur`), with `count` incremented.
6071
61−You can test this code by mounting your home desk with `|mount %`;
62−copying it into `home/gen/fizzbuzz.hoon` in your Urbit pier; then
63−typing `+fizzbuzz 100` in the Urbit dojo (shell).
72+You can test this code by mounting your home desk by entering
73+`|mount %` from the dojo; saving the above code as
74+`home/gen/fizzbuzz.hoon` in your Urbit pier; then typing
75+`+fizzbuzz 100` in the dojo.