on master help sign in
update 1.9
commitd8621cc319eec211758f5ddac6e325193b7a5c14 authortinnus-napbus <admin@tinnus-napbus.xyz> dateFri 15 Oct 2021, 01:17 (5 years ago) parent222ef82
1 file changed+13−14
content/docs/hoon/hoon-school/generators.md+13−14
content/docs/hoon/hoon-school/generators.md+13−14
@@ -16,9 +16,8 @@ There are three kinds of generators: naked, `%say`, and `%ask`. There also used
1616### Naked Generators
1717
1818A naked generator is simply a `gate`; that is, it is an anonymous function that
19−takes a `sample` (argument) and produces a [noun](/docs/glossary/noun/). All you need to do is write a
20−`gate` and put it into a file in the `/gen` directory. Let's take a look at a
21−very simple one:
19+takes a `sample` (argument) and produces a [noun](/docs/glossary/noun/). All you
20+need to do is write a `gate` and put it into a file in the `/gen` directory of a desk on your ship. Let's take a look at a very simple one:
2221
2322```hoon
2423|= a=*
@@ -26,7 +25,8 @@ a
2625```
2726
2827This generator takes one argument of any noun and produces it without any
29−changes. Once you put this into a file named `echo.hoon` in the `/gen` directory, you must make your ship recognize the change by inputting `|commit %home` in the dojo. You can then run it from the dojo:
28+changes. Put this into a file named `echo.hoon` in the `/gen` directory of your
29+`%base` desk. You must make your ship recognize the change by inputting `|commit %base` in the dojo. You can then run it from the dojo:
3030
3131```
3232> +echo 42
@@ -64,7 +64,7 @@ generator to see something more familiar:
6464```
6565
6666Now let's create a generator with two arguments instead of one. Save the code
67−below as `add.hoon` in the `/gen` directory.
67+below as `add.hoon` in the `/gen` directory of your `%base` desk.
6868
6969```hoon
7070|= [a=@ud b=@ud]
@@ -104,7 +104,7 @@ So, more formally, a `%say` generator is a `cell`. The head of that cell is the
104104output data and the `mark` describing that data.
105105
106106Below is an example of a `%say` generator. Save it to `add.hoon` in the `/gen`
107−directory.
107+directory of your `%base` desk.
108108
109109```hoon
110110:- %say
@@ -133,7 +133,7 @@ Recall that the rune `:-` produces a cell, with the first following expression
133133as its head and the second following expression as its tail.
134134
135135The expression above creates a cell with `%say` as the head. The tail is
136−the `|= *` expression on the line that follows.
136+the `|= *` expression on the line that follows.
137137
138138```hoon
139139|= *
@@ -141,10 +141,10 @@ the `|= *` expression on the line that follows.
141141(add 40 2)
142142```
143143
144−`|= *` constructs a [gate](/docs/glossary/gate/) that takes a noun. This [gate](/docs/glossary/gate/) will itself produce a
144+`|= *` constructs a [gate](/docs/glossary/gate/) that takes a noun. This [gate](/docs/glossary/gate/) will itself produce a
145145`cask`, which is cell formed by the prepending `:-`. The head of that `cask` is
146146`%noun` and the tail is the rest of the program, `(add 40 2)`. The tail of the
147−`cask` will be our actual data produced by the body of the program: in this
147+`cask` will be our actual data produced by the body of the program: in this
148148case, just adding 40 and 2 together.
149149
150150#### `%say` generators with arguments
@@ -216,7 +216,7 @@ second part, besides its position:
216216```
217217
218218Let's look at an example that uses all three parts. Save the code below in a
219−file called `dice.hoon` in your `/gen` directory.
219+file called `dice.hoon` in the `/gen` directory of your `%base` desk.
220220
221221```hoon
222222:- %say
@@ -311,7 +311,7 @@ to explain how this kind of generator works.
311311##### `%ask` example
312312
313313The code below is an `%ask` generator that checks if the user inputs "blue" when
314−prompted. Save it as `axe.hoon` in `/gen`.
314+prompted. Save it as `axe.hoon` in the `/gen` directory of your `%base` desk.
315315
316316```hoon
317317/- sole
@@ -379,7 +379,7 @@ This code might be familiar. Just as with their `%say` cousins, `%ask`
379379generators need to produce a `cell`, the head of which specifies what kind of
380380generator we are running.
381381
382−With `|= *`, we create a gate and ignore the standard arguments we are given,
382+With `|= *`, we create a gate and ignore the standard arguments we are given,
383383because we're not using them.
384384
385385```hoon
@@ -434,7 +434,6 @@ use to prompt the user. In the case of our example, we use `"color: "`.
434434**`produce`** is used to construct the output of the generator. In our example,
435435we produce a `tang`.
436436
437−
438437```hoon
439438|= t=tape
440439```
@@ -458,4 +457,4 @@ This is a [known issue](https://github.com/urbit/arvo/issues/840) to be resolved
458457
459458## Conclusion
460459
461−You've now reached the end of Chapter 1 of the Hoon tutorial. Ideally you should have a fair understanding of the fundamental concepts of subject-oriented programming: limbs, legs, faces, wings, arms, cores, gates, and [doors](/docs/glossary/door/). If you can master these concepts you should have little or no trouble learning to write substantial Hoon programs.
460+You've now reached the end of Chapter 1 of the Hoon tutorial. Ideally you should have a fair understanding of the fundamental concepts of subject-oriented programming: limbs, legs, faces, wings, arms, cores, gates, and [doors](/docs/glossary/door/). If you can master these concepts you should have little or no trouble learning to write substantial Hoon programs.