on master help sign in
various minor fixes in hoon tutorials
ece6841joshuareagan
docs.umd+1−1
@@ -17,7 +17,7 @@
17
17
18Check out the [technical overview](about/overview) for a high-level architecture description. To install and run Urbit head to the Using section, starting with the [installation guide](using/install) and continuing forward.
18Check out the [technical overview](about/overview) for a high-level architecture description. To install and run Urbit head to the Using section, starting with the [installation guide](using/install) and continuing forward.
19
19
20−To begin developing for Urbit, you can start by walking through the tutorial series for [Hoon](tutorials/ch1). Hoon is Urbit's high-level programming language. Anyone obsessed with math, theory, fundamentals of computation, etc., should start with [Nock](tutorials/nock), the low-level language to which Hoon is compiled.
20+To begin developing for Urbit, you can start by walking through the tutorial series for [Hoon](tutorials/hoon-ch1). Hoon is Urbit's high-level programming language. Anyone obsessed with math, theory, fundamentals of computation, etc., should start with [Nock](tutorials/nock), the low-level language to which Hoon is compiled.
21
21
22 ==
22 ==
23
23
docs/reference/rune.umd+1−1
@@ -10,7 +10,7 @@
10
10
11;div(class "book")
11;div(class "book")
12
12
13−## Constants (and Interpolations)
13+## Constants
14
14
15Hoon uses runes to form expressions, but not all expressions have runes in them. First, we have constant expressions (and also expressions that would be constant, but that they allow for interpolations):
15Hoon uses runes to form expressions, but not all expressions have runes in them. First, we have constant expressions (and also expressions that would be constant, but that they allow for interpolations):
16
16
docs/tutorials/hoon-ch1.umd+1−1
@@ -9,7 +9,7 @@
9
9
10Hoon is a high-level, statically typed, functional programming language, custom-designed for use with Urbit. For a functional language it has a surprisingly imperative style, and mastering it doesn't require knowing any advanced mathematics.
10Hoon is a high-level, statically typed, functional programming language, custom-designed for use with Urbit. For a functional language it has a surprisingly imperative style, and mastering it doesn't require knowing any advanced mathematics.
11
11
12−Hoon is an unusual language in several respects, both in syntax and semantics. It uses runes (i.e., ASCII digraphs) in place of keywords, and the spacing rules are a bit strict. A great deal can be expressed in few lines, though excessively compressed code tends to be hard to read. Hoon has surprisingly simple semantics, but mastering it requires learning concepts that don't have close analogues in other languages. We believe that Hoon, if properly taught, is relatively easy to learn and pleasant to use.
12+Hoon is an unusual language in several respects, both in syntax and semantics. It uses runes (i.e., ASCII digraphs) in place of keywords, and the spacing rules are a bit strict. A great deal can be expressed in few lines, though excessively compressed code tends to be hard to read. Hoon has surprisingly simple semantics, but mastering it requires learning concepts that don't have close analogues in other languages.
13
13
14This multi-chapter tutorial series is designed to teach you Hoon without assuming you have an extensive programming background. In fact, you should be able to follow much of it even if you have no programming experience at all, though of course experience helps. We strongly encourage you to try out all the examples of each lesson. These lessons are meant for the beginner but they aren't meant to be skimmed.
14This multi-chapter tutorial series is designed to teach you Hoon without assuming you have an extensive programming background. In fact, you should be able to follow much of it even if you have no programming experience at all, though of course experience helps. We strongly encourage you to try out all the examples of each lesson. These lessons are meant for the beginner but they aren't meant to be skimmed.
15
15
docs/tutorials/hoon-ch1/hoon-ch1-1.umd+4−4
@@ -2,7 +2,7 @@
2 navuptwo/'true'
2 navuptwo/'true'
3 next/'true'
3 next/'true'
4 sort/'1'
4 sort/'1'
5− title/'Getting Started'
5+ title/'1.1 Getting Started'
6 ==
6 ==
7;>
7;>
8
8
@@ -12,13 +12,13 @@ Before we begin working on Hoon you should first (1) have Urbit installed and (2
12
12
13## Installing Urbit
13## Installing Urbit
14
14
15−You can [install Urbit](../../using/install/) on any Mac or Unix machine. On Windows, make a virtual Linux machine using VirtualBox or a similar tool.
15+You can [install Urbit](../../../using/install/) on any Mac or Unix machine. On Windows, make a virtual Linux machine using VirtualBox or a similar tool.
16
16
17Once you're finished you can boot your very own urbit.
17Once you're finished you can boot your very own urbit.
18
18
19## What is an urbit?
19## What is an urbit?
20
20
21−An *urbit* is an Urbit virtual computer with persistent state that can connect to the Urbit network. (Note the lowercase 'u' here. 'Urbit' is the entire software stack, whereas 'an urbit' is a local instance.). Each urbit is associated with a unique number that plays three distinct roles: (1) it's an address on the Urbit network, (2) it's a cryptographic identity, and (3) it's (in principle) a human memorable name. Normally an urbit's name is represented as a string starting with `~`, as in `~zod` or `~taglux-nidsep`.
21+An *urbit* is an Urbit virtual computer with persistent state that can connect to the Urbit network. (Note the lowercase 'u' here. 'Urbit' is the entire software stack, whereas 'an urbit' is a local instance.) Each urbit is associated with a unique number that plays three distinct roles: (1) it's an address on the Urbit network, (2) it's a cryptographic identity, and (3) it's (in principle) a human memorable name. Normally an urbit's name is represented as a string starting with `~`, as in `~zod` or `~taglux-nidsep`.
22
22
23These may not look like numbers, but they are. Each urbit name is written in a base-256 format, where each 'digit' is a syllable. Imagine your phone number as a pronounceable string which sounds like a name in a foreign language. An ordinary user-level urbit is a 'planet', and it's named by a 32-bit number. The latter is represented as a four-syllable string; e.g., the planet name `~taglux-nidsep` is the number 6,095,360.
23These may not look like numbers, but they are. Each urbit name is written in a base-256 format, where each 'digit' is a syllable. Imagine your phone number as a pronounceable string which sounds like a name in a foreign language. An ordinary user-level urbit is a 'planet', and it's named by a 32-bit number. The latter is represented as a four-syllable string; e.g., the planet name `~taglux-nidsep` is the number 6,095,360.
24
24
@@ -104,7 +104,7 @@ We should note that your comet's state is [ACID](https://en.wikipedia.org/wiki/A
104
104
105You've already used a standard library function to produce one value, in the dojo. Now that your comet is running again, let's try another. Enter the number `17`.
105You've already used a standard library function to produce one value, in the dojo. Now that your comet is running again, let's try another. Enter the number `17`.
106
106
107−_We won't show the `~palnul_nocser:dojo> ` prompt from here on out. We'll just show the echoed command along with its result._
107+> We won't show the `~palnul_nocser:dojo> ` prompt from here on out. We'll just show the echoed command along with its result.
108
108
109You'll see:
109You'll see:
110
110
docs/tutorials/hoon-ch1/hoon-ch1-2.umd+18−18
@@ -2,7 +2,7 @@
2 navuptwo/'true'
2 navuptwo/'true'
3 next/'true'
3 next/'true'
4 sort/'2'
4 sort/'2'
5− title/'Nouns'
5+ title/'1.2 Nouns'
6 ==
6 ==
7;>
7;>
8
8
@@ -123,7 +123,7 @@ As for why the dojo deleted your zero: it parses the command line as you type, a
123
123
124Atoms are nothing more than unsigned integers, but it's often useful to interpret an atom as being a different kind of data. This is done with an *aura* -- the aura of an atom is type meta-data used by Hoon to determine how interpret that atom.
124Atoms are nothing more than unsigned integers, but it's often useful to interpret an atom as being a different kind of data. This is done with an *aura* -- the aura of an atom is type meta-data used by Hoon to determine how interpret that atom.
125
125
126−We won't fully explain auras and their various uses yet. Auras will be covered more comprehensively in a later lesson. For now let's just look at the various kinds of [literal syntax](https://en.wikipedia.org/wiki/Literal_(computer_programming)) associated with atom auras.
126+We won't fully explain auras and their various uses yet. Auras will be covered more comprehensively in a later lesson. For now let's just look at the various kinds of [literal syntax](https://en.wikipedia.org/wiki/Literal_(computer_programming%29) associated with atom auras.
127
127
128In computer science, a 'literal' is an expression that represents and evaluates to a fixed value. The default syntax of an atom literal is the German-style decimal notation, as seen above. Let's look at some other atom literal syntaxes: unsigned binary, unsigned hexadecimal, signed decimal, signed binary and hexadecimal.
128In computer science, a 'literal' is an expression that represents and evaluates to a fixed value. The default syntax of an atom literal is the German-style decimal notation, as seen above. Let's look at some other atom literal syntaxes: unsigned binary, unsigned hexadecimal, signed decimal, signed binary and hexadecimal.
129
129
@@ -296,7 +296,7 @@ You can force Hoon to interpret an atom differently by using the aura symbols in
296
296
297The atoms in the examples above are all exactly the same value. Only they're interpreted and printed differently, depending on the aura.
297The atoms in the examples above are all exactly the same value. Only they're interpreted and printed differently, depending on the aura.
298
298
299−For more on atoms and auras, see lesson XXXX.
299+You'll learn more about atoms and auras in [lesson 2.4](../../hoon-ch2/hoon-ch2-4).
300
300
301## Cells
301## Cells
302
302
@@ -471,24 +471,24 @@ That's it for our basic introduction to nouns. Hit `ctrl-d` to exit your comet,
471
471
472### 1.1.1
472### 1.1.1
473
473
474−1. No
474++ No
475−2. Yes
475++ Yes
476−3. No
476++ No
477−4. Yes
477++ Yes
478−5. Yes
478++ Yes
479
479
480### 1.1.2
480### 1.1.2
481
481
482−1. 86
482++ 86
483−2. [[[65 35] 54] 77]
483++ [[[65 35] 54] 77]
484−3. [65 35]
484++ [65 35]
485−4. 77
485++ 77
486−5. 3
486++ 3
487
487
488### 1.1.3
488### 1.1.3
489
489
490−1. +2
490++ +2
491−2. +6
491++ +6
492−3. +14
492++ +14
493−4. +15
493++ +15
494−5. +31
494++ +31
docs/tutorials/hoon-ch1/hoon-ch1-3.umd+22−21
@@ -2,7 +2,7 @@
2 navuptwo/'true'
2 navuptwo/'true'
3 next/'true'
3 next/'true'
4 sort/'3'
4 sort/'3'
5− title/'The Subject and Its Legs'
5+ title/'1.3 The Subject and Its Legs'
6 ==
6 ==
7;>
7;>
8
8
@@ -311,25 +311,26 @@ There is no restriction against using the same face name for multiple limbs of t
3115
3115
312```
312```
313
313
314−Why does this return `5` rather than `6` or `[14 15]`? When a face is evaluated against a subject, a head-first binary tree search occurs starting at address `1` of the subject. If there is no matching face for address `n` of the subject, first the head of `n` is searched and then `n`'s tail. The total search path for `[[4 b=5] [b=6 b=[14 15]]]` is:
314+Why does this return `5` rather than `6` or `[14 15]`? When a face is evaluated against a subject, a head-first binary tree search occurs starting at address `1` of the subject. If there is no matching face for address `n` of the subject, first the head of `n` is searched and then `n`'s tail. The complete search path for `[[4 b=5] [b=6 b=[14 15]]]` is:
315
315
316+
316−1. `[[4 b=5] [b=6 b=[14 15]]]`
317++ `[[4 b=5] [b=6 b=[14 15]]]`
317−1. `[4 b=5]`
318++ `[4 b=5]`
318−1. `4`
319++ `4`
319−1. `b=5`
320++ `b=5`
320−1. `[b=6 b=[14 15]]`
321++ `[b=6 b=[14 15]]`
321−1. `b=6`
322++ `b=6`
322−1. `b=[14 15]`
323++ `b=[14 15]`
323
324
324There are matches at steps 4, 6, and 7 of the total search path, but the search ends when the first match is found at step 4.
325There are matches at steps 4, 6, and 7 of the total search path, but the search ends when the first match is found at step 4.
325
326
326The children of legs bearing names aren't included in the search path. For example, the search path of `[[4 a=5] b=[c=14 15]]` is:
327The children of legs bearing names aren't included in the search path. For example, the search path of `[[4 a=5] b=[c=14 15]]` is:
327
328
328−1. `[[4 a=5] b=[c=14 15]]`
329++ `[[4 a=5] b=[c=14 15]]`
329−1. `[4 a=5]`
330++ `[4 a=5]`
330−1. `4`
331++ `4`
331−1. `a=5`
332++ `a=5`
332−1. `b=[c=14 15]`
333++ `b=[c=14 15]`
333
334
334Neither of the legs `c=14` or `15` is checked. Accordingly, a search for `c` of `[[4 a=5] b=[c=14 15]]` fails:
335Neither of the legs `c=14` or `15` is checked. Accordingly, a search for `c` of `[[4 a=5] b=[c=14 15]]` fails:
335
336
@@ -347,13 +348,13 @@ There are cases when you don't want the limb of the first matching face. You ca
347
348
348Recall that the search path for this noun is:
349Recall that the search path for this noun is:
349
350
350−1. `[[4 b=5] [b=6 b=[14 15]]]`
351++ `[[4 b=5] [b=6 b=[14 15]]]`
351−1. `[4 b=5]`
352++ `[4 b=5]`
352−1. `4`
353++ `4`
353−1. `b=5`
354++ `b=5`
354−1. `[b=6 b=[14 15]]`
355++ `[b=6 b=[14 15]]`
355−1. `b=6`
356++ `b=6`
356−1. `b=[14 15]`
357++ `b=[14 15]`
357
358
358The second match in the search path is step 6, `b=6`, so the value at that leg is produced. You can stack `^` characters to skip more than one matching face:
359The second match in the search path is step 6, `b=6`, so the value at that leg is produced. You can stack `^` characters to skip more than one matching face:
359
360
docs/tutorials/hoon-ch1/hoon-ch1-4.umd+3−3
@@ -2,7 +2,7 @@
2 navuptwo/'true'
2 navuptwo/'true'
3 next/'true'
3 next/'true'
4 sort/'4'
4 sort/'4'
5− title/'Arms and Cores'
5+ title/'1.4 Arms and Cores'
6 ==
6 ==
7;>
7;>
8
8
@@ -24,7 +24,7 @@ Now you just need to know what a 'Nock formula' is, what a 'battery' is, and wha
24
24
25Hoon runs on your urbit, which is a virtual computer. However, this virtual computer doesn't directly understand Hoon; it has a Nock interpreter instead. Any Hoon code you want to run must first be compiled to Nock. You certainly don't have to know Nock to understand Hoon, but it helps to be aware of a few of Nock's general features.
25Hoon runs on your urbit, which is a virtual computer. However, this virtual computer doesn't directly understand Hoon; it has a Nock interpreter instead. Any Hoon code you want to run must first be compiled to Nock. You certainly don't have to know Nock to understand Hoon, but it helps to be aware of a few of Nock's general features.
26
26
27−Nock is a [low-level](https://en.wikipedia.org/wiki/Low-level_programming_language), [functional programming](https://en.wikipedia.org/wiki/Functional_programming) language. As a consequence Nock itself can be understood as a function, called the 'Nock function'. Nock is officially defined by the Nock spec (link).
27+Nock is a [low-level](https://en.wikipedia.org/wiki/Low-level_programming_language), [functional programming](https://en.wikipedia.org/wiki/Functional_programming) language. As a consequence Nock itself can be understood as a function, called the 'Nock function'. Nock is officially defined by the [Nock spec](../../nock/definition).
28
28
29### What is a Function?
29### What is a Function?
30
30
@@ -45,7 +45,7 @@ Here's an example of some Nock run in the dojo, using `.*( )`:
45
45
46In this example `[15 17]` is the subject, `[[4 0 2] [0 3]]` is the formula, and `[16 17]` is the product.
46In this example `[15 17]` is the subject, `[[4 0 2] [0 3]]` is the formula, and `[16 17]` is the product.
47
47
48−This tutorial series is designed to teach you Hoon. For that purpose it's not important that you know how to read and understand Nock formulas; you just need to know that Nock takes a subject and a formula and returns a product. (Those who who want to learn more about Nock should head over to the Nock tutorial (link).)
48+This tutorial series is designed to teach you Hoon. For that purpose it's not important that you know how to read and understand Nock formulas; you just need to know that Nock takes a subject and a formula and returns a product. (Those who who want to learn more about Nock should head over to the [Nock tutorial]([Nock spec](../../nock)).)
49
49
50### Nock Formulas Define Functions
50### Nock Formulas Define Functions
51
51
docs/tutorials/hoon-ch1/hoon-ch1-5.umd+1−1
@@ -2,7 +2,7 @@
2 navuptwo/'true'
2 navuptwo/'true'
3 next/'true'
3 next/'true'
4 sort/'5'
4 sort/'5'
5− title/'Gates and Hoon Functions'
5+ title/'1.5 Gates and Hoon Functions'
6 ==
6 ==
7;>
7;>
8
8
docs/tutorials/hoon-ch1/hoon-ch1-6.umd+5−5
@@ -1,11 +1,11 @@
1:- :~ navhome/'/docs/'
1:- :~ navhome/'/docs/'
2 navuptwo/'true'
2 navuptwo/'true'
3 sort/'6'
3 sort/'6'
4− title/'Producing Gates with Cores'
4+ title/'1.6 Producing Gates with Core Arms'
5 ==
5 ==
6;>
6;>
7
7
8−# 1.6 Producing Gates with Cores
8+# 1.6 Producing Gates with Core Arms
9
9
10It's useful to have cores whose arms evaluate to make gates. The use of such cores is common in Hoon; that's how the functions of the Hoon standard library are stored in the subject. Learning about such cores will also deepen the reader's understanding of Hoon semantics, and for that reason alone is worthwhile.
10It's useful to have cores whose arms evaluate to make gates. The use of such cores is common in Hoon; that's how the functions of the Hoon standard library are stored in the subject. Learning about such cores will also deepen the reader's understanding of Hoon semantics, and for that reason alone is worthwhile.
11
11
@@ -274,7 +274,7 @@ battery .
274
274
275It follows from this definition that a gate is a special case of a door. A gate is a door with exactly one arm, named `$`.
275It follows from this definition that a gate is a special case of a door. A gate is a door with exactly one arm, named `$`.
276
276
277−Gates are useful for defining functions. But there are many-armed doors as well. How are they used? Doors are quite useful data structures. In Chapter 2 of the Hoon tutorial series you'll learn how to use doors to implement state machines, where the sample stores the relevant state data. For let's talk about how to use doors for simpler purposes.
277+Gates are useful for defining functions. But there are many-armed doors as well. How are they used? Doors are quite useful data structures. In Chapter 2 of the Hoon tutorial series you'll learn how to use doors to implement state machines, where the sample stores the relevant state data. For now let's talk about how to use doors for simpler purposes.
278
278
279### An Example Door
279### An Example Door
280
280
@@ -367,7 +367,7 @@ There's a more direct way of passing arguments for both the door sample and the
367%.n
367%.n
368```
368```
369
369
370−Readers of a particular mathematical background may notice that `~( )` expressions allow us to [curry](https://en.wikipedia.org/wiki/Currying). For each of the arms above, the `~( )` expression is used to create different versions of the same gate:
370+Readers with some mathematical background may notice that `~( )` expressions allow us to [curry](https://en.wikipedia.org/wiki/Currying). For each of the arms above, the `~( )` expression is used to create different versions of the same gate:
371
371
372```
372```
373> ~(plus c 7)
373> ~(plus c 7)
@@ -512,4 +512,4 @@ It's better simply to use the `~(arm rs arg)` syntax to replace the value of the
512
512
513## Conclusion
513## Conclusion
514
514
515−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. If you can master these concepts you should have little or no trouble learning to write substantial Hoon programs. Continue to Chapter 2 to get started.
515+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. If you can master these concepts you should have little or no trouble learning to write substantial Hoon programs. Continue to [Chapter 2](../../hoon-ch2) to get started.
docs/tutorials/hoon-ch2/hoon-ch2-1.umd+3−3
@@ -1,8 +1,8 @@
1:- :~ navhome/'/docs/'
1:- :~ navhome/'/docs/'
2 navuptwo/'true'
2 navuptwo/'true'
3 next/'true'
3 next/'true'
4− sort/'1'
4+ sort/'21'
5− title/'Hoon Programs'
5+ title/'2.1 Hoon Programs'
6 ==
6 ==
7;>
7;>
8
8
@@ -51,7 +51,7 @@ Save this as 'listnum.hoon' in `/home/gen` of your urbit's pier. To run it ente
51~[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24]
51~[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24]
52```
52```
53
53
54−### Function Programming, Runes, and Whitespace
54+### Functional Programming, Runes, and Whitespace
55
55
56Before going over how the above code works we should point out three things.
56Before going over how the above code works we should point out three things.
57
57
docs/tutorials/hoon-ch2/hoon-ch2-10.umd+2−2
@@ -1,8 +1,8 @@
1:- :~ navhome/'/docs/'
1:- :~ navhome/'/docs/'
2 navuptwo/'true'
2 navuptwo/'true'
3 next/'true'
3 next/'true'
4− sort/'10'
4+ sort/'30'
5− title/'Hoon Standard Library: Trees, Sets, and Maps'
5+ title/'2.10 Standard Library: Trees, Sets, and Maps'
6 ==
6 ==
7;>
7;>
8
8
docs/tutorials/hoon-ch2/hoon-ch2-11.umd+27−53
@@ -1,7 +1,7 @@
1:- :~ navhome/'/docs/'
1:- :~ navhome/'/docs/'
2 navuptwo/'true'
2 navuptwo/'true'
3− sort/'11'
3+ sort/'31'
4− title/'Examples'
4+ title/'2.11 Examples'
5 ==
5 ==
6;>
6;>
7
7
@@ -422,25 +422,15 @@ Specifically, for each iteration, each dead space becomes alive if and only if i
422 ##.
422 ##.
423```
423```
424
424
425−1. Write a function `next-generation` that takes nine flag
425++ Write a function `next-generation` that takes nine flag inputs, `nw`, `nc`, `ne`, `cw`, `cc`, `ce`, `sw`, `sc`, and `se`. Produce 'yes' if the center space will be alive in the next generation and 'no' if it will be dead.
426− inputs, `nw`, `nc`, `ne`, `cw`, `cc`, `ce`, `sw`, `sc`, and
427− `se`. Produce 'yes' if the center space will be alive in the
428− next generation and 'no' if it will be dead.
429
426
430−1. Write a function `create-board` that takes an integer `n` and
427++ Write a function `create-board` that takes an integer `n` and produces an `n` by `n` grid of flags, (hereafter, "board"), initialized to 'no'. This grid should be represented as a list of `n` lists of length `n`.
431− produces an `n` by `n` grid of flags, (hereafter,
432− "board"), initialized to 'no'. This grid should be
433− represented as a list of `n` lists of length `n`.
434
428
435−1. Write a function `toggle-space` that takes a board, a row
436− index, and a column index, and produces a new board,
437− identical to the old except that the state of the space
438− referred to by the row and column indices has been toggled.
429++ Write a function `toggle-space` that takes a board, a row index, and a column index, and produces a new board, identical to the old except that the state of the space referred to by the row and column indices has been toggled.
439
430
440−1. Use the following function `print-board` to pretty-print the
431++ Use the following function `print-board` to pretty-print the board. For bonus points, try to follow what it's doing.
441− board. For bonus points, try to follow what it's doing.
442
432
443− ```
433+ ```
444 |= board=(list (list ?))
434 |= board=(list (list ?))
445 ^- tang
435 ^- tang
446 %+ turn board
436 %+ turn board
@@ -452,23 +442,18 @@ Specifically, for each iteration, each dead space becomes alive if and only if i
452 ?: space
442 ?: space
453 '# '
443 '# '
454 '. '
444 '. '
455− ```
445+ ```
456−
446+
457− If you run this function with a board, you'll get a
447+ If you run this function with a board, you'll get a
458− pretty-printable object (a `tang`), but it won't be
448+ pretty-printable object (a `tang`), but it won't be
459− pretty-printed. When running the generator from the dojo,
449+ pretty-printed. When running the generator from the dojo,
460− run `&tang +generator arguments` to mark the result as a
450+ run `&tang +generator arguments` to mark the result as a
461− `tang`, which will tell the dojo to pretty-print it
451+ `tang`, which will tell the dojo to pretty-print it
462− appropriately.
452+ appropriately.
463−
453+
464−1. Using the functions created in the previous exercises, create
454++ Using the functions created in the previous exercises, create a 10 by 10 board, and flip the states of the spaces at coordinates (counting from the top left, indexed from 0) `(2,1)`, `(3,2)`, `(1,3)`, `(2,3)`, and `(3,3)`. Use the pretty printer to print out the board. Your output should be the following:
465− a 10 by 10 board, and flip the states of the spaces at
455+
466− coordinates (counting from the top left, indexed from 0)
467− `(2,1)`, `(3,2)`, `(1,3)`, `(2,3)`, and `(3,3)`. Use the
468− pretty printer to print out the board. Your output should be
469− the following:
470−
471− ```
456+ ```
472 . . . . . . . . . .
457 . . . . . . . . . .
473 . . # . . . . . . .
458 . . # . . . . . . .
474 . . . # . . . . . .
459 . . . # . . . . . .
@@ -479,12 +464,11 @@ Specifically, for each iteration, each dead space becomes alive if and only if i
479 . . . . . . . . . .
464 . . . . . . . . . .
480 . . . . . . . . . .
465 . . . . . . . . . .
481 . . . . . . . . . .
466 . . . . . . . . . .
482− ```
467+ ```
483
468
484−1. Write a function `step` that iterates every space on the
469++ Write a function `step` that iterates every space on the board. Print out the new board. It should look like this:
485− board. Print out the new board. It should look like this:
486
470
487− ```
471+ ```
488 . . . . . . . . . .
472 . . . . . . . . . .
489 . . . . . . . . . .
473 . . . . . . . . . .
490 . # . # . . . . . .
474 . # . # . . . . . .
@@ -495,22 +479,12 @@ Specifically, for each iteration, each dead space becomes alive if and only if i
495 . . . . . . . . . .
479 . . . . . . . . . .
496 . . . . . . . . . .
480 . . . . . . . . . .
497 . . . . . . . . . .
481 . . . . . . . . . .
498− ```
482+ ```
499
483
500− > Note that the spaces on the edge don't have the full nine
484+ > Note that the spaces on the edge don't have the full nine neighbors. For now, assume that they're always dead.
501− > neighbors. For now, assume that they're always dead.
502
485
503−1. Write a function `life` that runs the above function `n`
504− times on the board. Observe the board as the game
505− progresses. Congratulations, you've written Conway's Game of
486++ Write a function `life` that runs the above function `n` times on the board. Observe the board as the game progresses. Congratulations, you've written Conway's Game of Life in Hoon!
506− Life in Hoon!
507
487
508−1. One common way to handle the edge of the board is to pretend
488++ One common way to handle the edge of the board is to pretend that it "wraps around", forming a torus. In other words, say that the spaces on the left edge of the map are adjacent to the ones on the right edge, and the spaces on the top edge are adjacent to the spaces on the bottom edge. Modify `step` to act this way. Pay special attention to the corners.
509− that it "wraps around", forming a torus. In other words, say
510− that the spaces on the left edge of the map are adjacent to
511− the ones on the right edge, and the spaces on the top edge
512− are adjacent to the spaces on the bottom edge. Modify `step`
513− to act this way. Pay special attention to the corners.
514
489
515−1. Modify `create-board` to use `++og` to randomly initialize
490++ Modify `create-board` to use `++og` to randomly initialize the board with live or dead spaces.
516− the board with live or dead spaces.
docs/tutorials/hoon-ch2/hoon-ch2-2.umd+20−20
@@ -1,8 +1,8 @@
1:- :~ navhome/'/docs/'
1:- :~ navhome/'/docs/'
2 navuptwo/'true'
2 navuptwo/'true'
3 next/'true'
3 next/'true'
4− sort/'2'
4+ sort/'22'
5− title/'Hoon Syntax'
5+ title/'2.2 Hoon Syntax'
6 ==
6 ==
7;>
7;>
8
8
@@ -10,9 +10,9 @@
10
10
11The study of Hoon can be divided into two parts: syntax and semantics.
11The study of Hoon can be divided into two parts: syntax and semantics.
12
12
13−The [syntax](https://en.wikipedia.org/wiki/Syntax_(programming_languages)) of a programming language is the set of rules that determine what counts as admissible code in that language. It determines which characters may be used in the source, and also how these characters may be assembled to constitute a program. Failing to follow these rules when writing a program and then trying to run it will result in a syntax error.
13+The [syntax](https://en.wikipedia.org/wiki/Syntax_(programming_languages%29) of a programming language is the set of rules that determine what counts as admissible code in that language. It determines which characters may be used in the source, and also how these characters may be assembled to constitute a program. Failing to follow these rules when writing a program and then trying to run it will result in a syntax error.
14
14
15−The [semantics](https://en.wikipedia.org/wiki/Semantics_(computer_science)) of a programming language concerns the meaning of the various parts of that language's code.
15+The [semantics](https://en.wikipedia.org/wiki/Semantics_(computer_science%29) of a programming language concerns the meaning of the various parts of that language's code.
16
16
17In this lesson we cover Hoon's syntax. A strict account of Hoon's syntax would refrain from making any reference at all to semantics, but for ease of exposition we won't be quite so fastidious.
17In this lesson we cover Hoon's syntax. A strict account of Hoon's syntax would refrain from making any reference at all to semantics, but for ease of exposition we won't be quite so fastidious.
18
18
@@ -56,7 +56,7 @@ Note that the list includes two separate whitespace forms: `ace` for a single sp
56
56
57## Expressions of Hoon
57## Expressions of Hoon
58
58
59−An [expression](https://en.wikipedia.org/wiki/Expression_(computer_science)) is a combination of characters that the language interprets and evaluates as producing a value. Hoon programs are made up entirely of expressions.
59+An [expression](https://en.wikipedia.org/wiki/Expression_(computer_science%29) is a combination of characters that the language interprets and evaluates as producing a value. Hoon programs are made up entirely of expressions.
60
60
61Hoon expressions can be either basic or complex. Basic expressions of Hoon are fundamental, meaning that they can't be broken down into smaller expressions. Complex expressions are made up of smaller expressions (which are called *subexpressions*).
61Hoon expressions can be either basic or complex. Basic expressions of Hoon are fundamental, meaning that they can't be broken down into smaller expressions. Complex expressions are made up of smaller expressions (which are called *subexpressions*).
62
62
@@ -66,7 +66,7 @@ There are many categories of Hoon expressions: noun literals, wing expressions,
66
66
67A noun is either an atom or a cell. An atom is an unsigned integer and a cell is a pair of nouns.
67A noun is either an atom or a cell. An atom is an unsigned integer and a cell is a pair of nouns.
68
68
69−There are [literal](https://en.wikipedia.org/wiki/Literal_(computer_programming)) expressions for each kind of noun. A noun literal is just a notation for representing a fixed noun value.
69+There are [literal](https://en.wikipedia.org/wiki/Literal_(computer_programming%29) expressions for each kind of noun. A noun literal is just a notation for representing a fixed noun value.
70
70
71We start with atom literals. Each of these is a basic expression of Hoon that evaluates to itself. Examples:
71We start with atom literals. Each of these is a basic expression of Hoon that evaluates to itself. Examples:
72
72
@@ -93,7 +93,7 @@ We start with atom literals. Each of these is a basic expression of Hoon that e
930b1101.1001
930b1101.1001
94```
94```
95
95
96−Recall from lesson 1.2 (link) that even though atoms are unsigned integers, they can be pretty-printed in different ways. The way an atom is to be represented depends on its aura. The literal syntax for each of the hard-coded auras will be explained further in lesson XXXX.
96+Recall from [lesson 1.2](../../hoon-ch1/hoon-ch1-2) that even though atoms are unsigned integers, they can be pretty-printed in different ways. The way an atom is to be represented depends on its aura. The literal syntax for each of the hard-coded auras will be explained further in [lesson 2.4](../hoon-ch2-4).
97
97
98Cell literals can be written in Hoon using `[ ]`. Cell literals are complex, because other expressions are put inside the square brackets. Examples:
98Cell literals can be written in Hoon using `[ ]`. Cell literals are complex, because other expressions are put inside the square brackets. Examples:
99
99
@@ -111,7 +111,7 @@ Cell literals can be written in Hoon using `[ ]`. Cell literals are complex, be
111[123 [~zod ~ten] .1.2837]
111[123 [~zod ~ten] .1.2837]
112```
112```
113
113
114−A murkier case involves putting complex expressions inside square brackets to make a cell. These are valid expressions but they aren't cell literals, naturally:
114+You can also put complex expressions inside square brackets to make a cell. These are valid expressions but they aren't cell literals, naturally:
115
115
116```
116```
117> [(add 22 33) (mul 22 33)]
117> [(add 22 33) (mul 22 33)]
@@ -120,7 +120,7 @@ A murkier case involves putting complex expressions inside square brackets to ma
120
120
121### Wings
121### Wings
122
122
123−A wing expression is a series of limb expressions separated by `.`. You learned about these in sections 1.3 (link) and 1.4 (link).
123+A wing expression is a series of limb expressions separated by `.`. You learned about these in [sections 1.3](../../hoon-ch1/hoon-ch1-3) and [sections 1.4](../../hoon-ch1/hoon-ch1-4).
124
124
125Let's start with the base case: a single limb. A limb expression is a trivial wing expression -- there is only one limb in the series. Some one-limb wings:
125Let's start with the base case: a single limb. A limb expression is a trivial wing expression -- there is only one limb in the series. Some one-limb wings:
126
126
@@ -134,7 +134,7 @@ Let's start with the base case: a single limb. A limb expression is a trivial w
134- `mul`
134- `mul`
135- `kebab-case-123`
135- `kebab-case-123`
136
136
137−As a special limb we also have `$`. This is the name of the arm in special one-armed cores called "gates". (We covered the role of `$` in lesson 1.5 (link).)
137+As a special limb we also have `$`. This is the name of the arm in special one-armed cores called "gates". (We covered the role of `$` in [lesson 1.5](../../hoon-ch1/hoon-ch1-5).)
138
138
139Wing expressions with multiple limbs are complex expressions. Examples:
139Wing expressions with multiple limbs are complex expressions. Examples:
140
140
@@ -150,7 +150,7 @@ Wing expressions with multiple limbs are complex expressions. Examples:
150
150
151Hoon is a statically typed language. You'll learn more about the type system later in the chapter. For now, just know that Hoon's type system uses special symbols to indicate certain fundamental types: `~` (null), `*` (noun), `@` (atom), `^` (cell), and `?` (flag). Each of these symbols can be used as a stand-alone expression of Hoon. In the case of `@` there may be a series of letters following it, to indicate an atom aura; e.g., `@s`, `@rs`, `@tas`, and `@tD`.
151Hoon is a statically typed language. You'll learn more about the type system later in the chapter. For now, just know that Hoon's type system uses special symbols to indicate certain fundamental types: `~` (null), `*` (noun), `@` (atom), `^` (cell), and `?` (flag). Each of these symbols can be used as a stand-alone expression of Hoon. In the case of `@` there may be a series of letters following it, to indicate an atom aura; e.g., `@s`, `@rs`, `@tas`, and `@tD`.
152
152
153−They may also be put in brackets to indicate compound types, e.g., `[@ ^]`, `[@ud @sb]`, `[[? *] ^]`. (Technically these expressions don't _always_ indicate compound types. In certain contexts they're interpreted in a different way. We'll address this variation of meaning in lesson XXXX.)
153+They may also be put in brackets to indicate compound types, e.g., `[@ ^]`, `[@ud @sb]`, `[[? *] ^]`. (Technically these expressions don't _always_ indicate compound types. In certain contexts they're interpreted in a different way. We'll address this variation of meaning in [lesson 2.6](../hoon-ch2-6).)
154
154
155### Rune Expressions
155### Rune Expressions
156
156
@@ -168,7 +168,7 @@ There are two rune syntax forms: *tall* and *flat*. Tall form is usually used f
168
168
169The spacing rules differ in the two forms. In tall form, each rune and subexpression must be separated from the others by a `gap` -- that is, by two or more spaces, or a line break. In flat form the rune is immediately followed by parentheses `( )`, and the various subexpressions inside the parentheses must be separated from the others by an `ace` -- that is, by a single space.
169The spacing rules differ in the two forms. In tall form, each rune and subexpression must be separated from the others by a `gap` -- that is, by two or more spaces, or a line break. In flat form the rune is immediately followed by parentheses `( )`, and the various subexpressions inside the parentheses must be separated from the others by an `ace` -- that is, by a single space.
170
170
171−Seeing an example will help you understand the difference. The `:-` rune is used to produce a cell. Accordingly, it is followed by two subexpressions: the first defines the head of the cell, and the second defines the tail. Here are three different ways to write a `:-` hoon in tall form:
171+Seeing an example will help you understand the difference. The `:-` rune is used to produce a cell. Accordingly, it is followed by two subexpressions: the first defines the head of the cell, and the second defines the tail. Here are three different ways to write a `:-` expression in tall form:
172
172
173```
173```
174> :- 11 22
174> :- 11 22
@@ -184,18 +184,18 @@ Seeing an example will help you understand the difference. The `:-` rune is use
184[11 22]
184[11 22]
185```
185```
186
186
187−These all do the same thing. The first example shows that, if you really want to, you can write 'tall' form code on a single line. Notice that there are two spaces between the `:-` rune and `11`, and also between `11` and `22`. This is the minimum spacing necessary between the various parts of a tall form expression -- any fewer will result in a syntax error.
187+These all do the same thing. The first example shows that, if you want to, you can write 'tall' form code on a single line. Notice that there are two spaces between the `:-` rune and `11`, and also between `11` and `22`. This is the minimum spacing necessary between the various parts of a tall form expression -- any fewer will result in a syntax error.
188
188
189−Usually one or more line breaks are used to break up a tall form expression. This is especially useful when the subexpressions are themselves long stretches of code. The same `:-` hoon in flat-form is:
189+Usually one or more line breaks are used to break up a tall form expression. This is especially useful when the subexpressions are themselves long stretches of code. The same `:-` expression in flat-form is:
190
190
191```
191```
192> :-(11 22)
192> :-(11 22)
193[11 22]
193[11 22]
194```
194```
195
195
196−This is the preferred way to write a hoon on a single line. The rune itself is followed by a set of parentheses, and the subexpressions inside are separated by a single space. Any more spacing than that results in a syntax error.
196+This is the preferred way to write an expression on a single line. The rune itself is followed by a set of parentheses, and the subexpressions inside are separated by a single space. Any more spacing than that results in a syntax error.
197
197
198−Nearly all rune expressions can be written in either form, but there are exceptions. The `|%` and `|_` expressions, for example, can only be written in tall form. (Those (link) are a bit too complicated to fit comfortably on one line anyway.)
198+Nearly all rune expressions can be written in either form, but there are exceptions. `|%` and `|_` expressions, for example, can only be written in tall form. (Those are a bit too complicated to fit comfortably on one line anyway.)
199
199
200#### Irregular Forms
200#### Irregular Forms
201
201
@@ -264,7 +264,7 @@ The irregular `( )` gate-calling syntax is versatile -- it is also a shortcut fo
264
264
265The `( )` gate-calling syntax can be used for gates of any other [arity](https://en.wikipedia.org/wiki/Arity) as well.
265The `( )` gate-calling syntax can be used for gates of any other [arity](https://en.wikipedia.org/wiki/Arity) as well.
266
266
267−You've already seen two other irregular forms. In lesson 1.5 (link), you made a gate that takes an atom `a` for its sample and returns `a + 1`: `|=(a=@ (add 1 a))`. This expression uses the `|=` rune in flat form.
267+You've already seen two other irregular forms. In [lesson 1.5](../../hoon-ch1/hoon-ch1-5), you made a gate that takes an atom `a` for its sample and returns `a + 1`: `|=(a=@ (add 1 a))`. This expression uses the `|=` rune in flat form.
268
268
269```
269```
270> =inc |=(a=@ (add 1 a))
270> =inc |=(a=@ (add 1 a))
@@ -308,7 +308,7 @@ The `a=15` expression is the irregular form of `^=(a 15)`:
30835
30835
309```
309```
310
310
311−You can find other irregular forms in the irregular expression reference document (link).
311+You can find other irregular forms in the irregular expression [reference document](../../../reference/irregular).
312
312
313### Expressions That Are Only Irregular
313### Expressions That Are Only Irregular
314
314
@@ -349,7 +349,7 @@ b=[16 18]
349[16 18]
349[16 18]
350```
350```
351
351
352−To see other irregular expressions, check the irregular expression reference document (link).
352+To see other irregular expressions, check the irregular expression [reference document](../../../reference/irregular).
353
353
354## Hoon Style
354## Hoon Style
355
355
@@ -444,7 +444,7 @@ In optimal usage of backstep indentation the most complicated subexpressions are
444
444
445#### Running
445#### Running
446
446
447−A *running* body doesn't have a fixed number of subexpressions; hoons with running bodies can be arbitrarily long.
447+A *running* body doesn't have a fixed number of subexpressions; expressions with running bodies can be arbitrarily long.
448
448
449To indicate the end of such expressions in tall form, use the `==` rune. The first subexpression is two spaces after the initial rune, and all others are indented to line up with the first. The terminating `==` should align vertically with the initial rune. In flat form, parentheses are used around the expression body, so the terminating `==` is unnecessary.
449To indicate the end of such expressions in tall form, use the `==` rune. The first subexpression is two spaces after the initial rune, and all others are indented to line up with the first. The terminating `==` should align vertically with the initial rune. In flat form, parentheses are used around the expression body, so the terminating `==` is unnecessary.
450
450
docs/tutorials/hoon-ch2/hoon-ch2-3.umd+7−7
@@ -1,14 +1,14 @@
1:- :~ navhome/'/docs/'
1:- :~ navhome/'/docs/'
2 navuptwo/'true'
2 navuptwo/'true'
3 next/'true'
3 next/'true'
4− sort/'3'
4+ sort/'23'
5− title/'Simple One-Gate Programs'
5+ title/'2.3 Simple One-Gate Programs'
6 ==
6 ==
7;>
7;>
8
8
9# Simple One-Gate Programs
9# Simple One-Gate Programs
10
10
11−In this lesson we'll try to cover enough basic Hoon so that you can write (and understand!) your own simple programs. Each of the programs given in this lesson defines a gate. (Gates are one-armed cores of Hoon that can be used as functions -- this is covered in lesson 1.5 (link).)
11+In this lesson we'll try to cover enough basic Hoon so that you can write (and understand!) your own simple programs. Each of the programs given in this lesson defines a gate. (Gates are one-armed cores of Hoon that can be used as functions -- this is covered in [lesson 1.5](../../hoon-ch1/hoon-ch1-5).)
12
12
13For each program we encourage you to: (1) write out the program yourself, (2) save it to the `/home/gen` directory of your urbit's pier, and (3) run it from the dojo. The best way to learn to program in Hoon is by getting your hands dirty.
13For each program we encourage you to: (1) write out the program yourself, (2) save it to the `/home/gen` directory of your urbit's pier, and (3) run it from the dojo. The best way to learn to program in Hoon is by getting your hands dirty.
14
14
@@ -20,7 +20,7 @@ Let's look at a really simple gate: `|=(a=@ 15)`. This gate takes any atom as i
20
20
21The `|=` rune takes two subexpressions. The first must indicate a type, and the second may evaluate to any value. The first defines the gate's sample type and possibly binds a face to it, and the second defines the output of the gate. In the example `|=(a=@ 15)` the `|=` subexpressions are `a=@` and `15`.
21The `|=` rune takes two subexpressions. The first must indicate a type, and the second may evaluate to any value. The first defines the gate's sample type and possibly binds a face to it, and the second defines the output of the gate. In the example `|=(a=@ 15)` the `|=` subexpressions are `a=@` and `15`.
22
22
23−The following characters represent basic Hoon types: `@` for atoms, `^` for cells, `?` for flags, and `*` for nouns. You should already know what atoms, cells, and nouns are. (See lesson 1.2 (link) if you need a reminder.) There are two values for the `?` type: `%.y` for yes, and `%.n` for no. In other words, `?` is for the [Boolean values](https://en.wikipedia.org/wiki/Boolean_data_type) of Hoon.
23+The following characters represent basic Hoon types: `@` for atoms, `^` for cells, `?` for flags, and `*` for nouns. You should already know what atoms, cells, and nouns are. (See [lesson 1.2](../../hoon-ch1/hoon-ch1-2) if you need a reminder.) There are two values for the `?` type: `%.y` for yes, and `%.n` for no. In other words, `?` is for the [Boolean values](https://en.wikipedia.org/wiki/Boolean_data_type) of Hoon.
24
24
25You could have picked a different type for the first subexpression of `|=(a=@ 15)` and left off the face. To illustrate this let's call different versions of the gate with the `(gate arg)` function call syntax:
25You could have picked a different type for the first subexpression of `|=(a=@ 15)` and left off the face. To illustrate this let's call different versions of the gate with the `(gate arg)` function call syntax:
26
26
@@ -561,7 +561,7 @@ This rune is often used for modifying the value of a face whose value was set be
561
561
562## Recursion
562## Recursion
563
563
564−How do we do loops in Hoon? Like other functional programming languages Hoon uses [recursion](https://en.wikipedia.org/wiki/Recursion_(computer_science)). In rough terms, a recursive function solves a problem in part by calling on itself to solve a slightly easier or smaller case of the same problem. The self-calling loop continues until the simplified problem is so simple that it has a trivial solution.
564+How do we do loops in Hoon? Like other functional programming languages Hoon uses [recursion](https://en.wikipedia.org/wiki/Recursion_(computer_science%29). In rough terms, a recursive function solves a problem in part by calling on itself to solve a slightly easier or smaller case of the same problem. The self-calling loop continues until the simplified problem is so simple that it has a trivial solution.
565
565
566Seeing an example will make this process easier to understand.
566Seeing an example will make this process easier to understand.
567
567
@@ -634,7 +634,7 @@ The `$( )` syntax is an irregular form of the the `%=` rune. We can rewrite tha
634
634
635This version is precisely equivalent to the old one. The first `%=` subexpression is for a wing. In the program above, this is just `$`. The other subexpressions of `%=` indicate the changes to be made upon resolution to the wing. You can make as many of these changes as desired when using `%=`, so the expression is ended with `==`.
635This version is precisely equivalent to the old one. The first `%=` subexpression is for a wing. In the program above, this is just `$`. The other subexpressions of `%=` indicate the changes to be made upon resolution to the wing. You can make as many of these changes as desired when using `%=`, so the expression is ended with `==`.
636
636
637−Remember from lessons 1.4-1.5 (links) that wing resolution works in two different ways. If the wing resolves to a leg, that fragment of the subject is returned. If the wing resolves to an arm, the arm is evaluated with its parent core as the subject. In lesson 1.5 (link) you learned that `$` is the special name of the arm of a gate. (Remember, a gate is a one-armed core with a sample.) Because we wrote `add.hoon` with `|=` it produces a gate. The `%=` expression above thus evaluates the `$` arm of the gate, but only after having made changes to the parent core: `a` is incremented, and `b` is decremented.
637+Remember from lessons [1.4](../../hoon-ch1/hoon-ch1-4) and [1.5](../../hoon-ch1/hoon-ch1-5) that wing resolution works in two different ways. If the wing resolves to a leg, that fragment of the subject is returned. If the wing resolves to an arm, the arm is evaluated with its parent core as the subject. In [lesson 1.5](../../hoon-ch1/hoon-ch1-5) you learned that `$` is the special name of the arm of a gate. (Remember, a gate is a one-armed core with a sample.) Because we wrote `add.hoon` with `|=` it produces a gate. The `%=` expression above thus evaluates the `$` arm of the gate, but only after having made changes to the parent core: `a` is incremented, and `b` is decremented.
638
638
639### Decrement
639### Decrement
640
640
@@ -736,7 +736,7 @@ Write a program that takes a number `n` and returns `%.y` if it's prime, and `%.
736
736
737Let's write a Hoon implementation of [FizzBuzz](https://en.wikipedia.org/wiki/Fizz_buzz). Fizzbuzz takes some number `n` and then makes a list of numbers from `1` to `n`, except that numbers evenly divisible by `3` are replaced with 'Fizz', numbers evenly divisible by `5` are replaced with 'Buzz', and numbers evenly divisible by both are replaced with 'FizzBuzz'.
737Let's write a Hoon implementation of [FizzBuzz](https://en.wikipedia.org/wiki/Fizz_buzz). Fizzbuzz takes some number `n` and then makes a list of numbers from `1` to `n`, except that numbers evenly divisible by `3` are replaced with 'Fizz', numbers evenly divisible by `5` are replaced with 'Buzz', and numbers evenly divisible by both are replaced with 'FizzBuzz'.
738
738
739−You already saw a program that produces a list of atoms from `1` to `n` in lesson 2.1 (link), `listnum.hoon`:
739+You already saw a program that produces a list of atoms from `1` to `n` in [lesson 2.1](../hoon-ch2-1), `listnum.hoon`:
740
740
741```
741```
742|= end=@ :: 1
742|= end=@ :: 1
docs/tutorials/hoon-ch2/hoon-ch2-4.umd+6−6
@@ -1,14 +1,14 @@
1:- :~ navhome/'/docs/'
1:- :~ navhome/'/docs/'
2 navuptwo/'true'
2 navuptwo/'true'
3 next/'true'
3 next/'true'
4− sort/'4'
4+ sort/'24'
5− title/'Intro to Types: Atoms, Auras, and Simple Cell Types'
5+ title/'2.4 Atoms, Auras, and Simple Cell Types'
6 ==
6 ==
7;>
7;>
8
8
9−# Types Pt. 1: Atoms, Auras, and Simple Cell Types
9+# Atoms, Auras, and Simple Cell Types
10
10
11−Like most modern high-level programming languages, Hoon has a type system. Because Hoon is a functional programming language, its type system differs somewhat from those of non-functional languages. In the next few lessons we'll go over Hoon's type system and point out some of its distinctive features. Certain advanced topics (e.g. type [polymorphism](https://en.wikipedia.org/wiki/Polymorphism_(computer_science))) won't be addressed until a later chapter.
11+Like most modern high-level programming languages, Hoon has a type system. Because Hoon is a functional programming language, its type system differs somewhat from those of non-functional languages. In the next few lessons we'll go over Hoon's type system and point out some of its distinctive features. Certain advanced topics (e.g. type [polymorphism](https://en.wikipedia.org/wiki/Polymorphism_(computer_science%29)) won't be addressed until a later chapter.
12
12
13A type is ordinarily understood to be a set of values. Examples: the set of all atoms is a type, the set of all cells is a type, and so on.
13A type is ordinarily understood to be a set of values. Examples: the set of all atoms is a type, the set of all cells is a type, and so on.
14
14
@@ -22,13 +22,13 @@ In this lesson we'll cover (1)-(4) as they pertain to atoms and simple cell type
22
22
23## Atoms and Auras
23## Atoms and Auras
24
24
25−In lesson 1.2 (link) we defined what an atom is: any unsigned integer. In this lesson we'll expand on that discussion, going over how Hoon's type system implements auras.
25+In [lesson 1.2](../../hoon-ch1/hoon-ch1-2) we defined what an atom is: any unsigned integer. In this lesson we'll expand on that discussion, going over how Hoon's type system implements auras.
26
26
27In the most straightforward sense, atoms simply are unsigned integers. But they can also be interpreted as representing signed integers, ASCII symbols, floating-point values, dates, binary numbers, hexadecimal numbers, and more. Every atom is, in and of itself, just an unsigned integer; but Hoon keeps track of type information about each atom, and this info tells Hoon how to interpret the atom in question.
27In the most straightforward sense, atoms simply are unsigned integers. But they can also be interpreted as representing signed integers, ASCII symbols, floating-point values, dates, binary numbers, hexadecimal numbers, and more. Every atom is, in and of itself, just an unsigned integer; but Hoon keeps track of type information about each atom, and this info tells Hoon how to interpret the atom in question.
28
28
29The piece of type information that determines how Hoon interprets an atom is called an *aura*. The set of all atoms is indicated with the symbol `@`. An aura is indicated with `@` followed by some letters, e.g., `@ud` for unsigned decimal. Accordingly, the Hoon type system does more than track sets of values. It also tracks certain other relevant metadata about how those values are to be interpreted.
29The piece of type information that determines how Hoon interprets an atom is called an *aura*. The set of all atoms is indicated with the symbol `@`. An aura is indicated with `@` followed by some letters, e.g., `@ud` for unsigned decimal. Accordingly, the Hoon type system does more than track sets of values. It also tracks certain other relevant metadata about how those values are to be interpreted.
30
30
31−How is aura information generated so that it can be tracked? One way involves *type inference*. In certain cases Hoon's type system can infer the type of an expression using syntactic clues. In the most straightforward case of type inference, the expression is simply data as a [literal](https://en.wikipedia.org/wiki/Literal_(computer_programming)). Hoon recognizes the aura literal syntax and infers that the data in question is an atom with the aura associated with that syntax.
31+How is aura information generated so that it can be tracked? One way involves *type inference*. In certain cases Hoon's type system can infer the type of an expression using syntactic clues. In the most straightforward case of type inference, the expression is simply data as a [literal](https://en.wikipedia.org/wiki/Literal_(computer_programming%29). Hoon recognizes the aura literal syntax and infers that the data in question is an atom with the aura associated with that syntax.
32
32
33To see the inferred type of a literal expression in the dojo, use the `?` operator. (Note: this operator isn't part of the Hoon programming language; it's a dojo-only tool. It's a very useful tool for learning Hoon, however.)
33To see the inferred type of a literal expression in the dojo, use the `?` operator. (Note: this operator isn't part of the Hoon programming language; it's a dojo-only tool. It's a very useful tool for learning Hoon, however.)
34
34
docs/tutorials/hoon-ch2/hoon-ch2-5.umd+4−4
@@ -1,8 +1,8 @@
1:- :~ navhome/'/docs/'
1:- :~ navhome/'/docs/'
2 navuptwo/'true'
2 navuptwo/'true'
3 next/'true'
3 next/'true'
4− sort/'5'
4+ sort/'25'
5− title/'Type Checking and Type Inference'
5+ title/'2.5 Type Checking and Type Inference'
6 ==
6 ==
7;>
7;>
8
8
@@ -144,7 +144,7 @@ It's helpful to know *that* Hoon infers the type of any given expression, but it
144
144
145### Literals
145### Literals
146
146
147−[Literals](https://en.wikipedia.org/wiki/Literal_(computer_programming)) are expressions that represent fixed values. Some examples (with the inferred type on the right):
147+[Literals](https://en.wikipedia.org/wiki/Literal_(computer_programming%29) are expressions that represent fixed values. Some examples (with the inferred type on the right):
148
148
149```
149```
150123 @ud
150123 @ud
@@ -482,7 +482,7 @@ This code is a little more tricky. The basic idea, however, is simple. We have
482
482
483What makes this program is little harder to follow is that it has a recursion call within a recursion call. The first recursion expression on line 6 makes changes to two face values: `c`, the counter, and `a`, the input noun. The new value for `c` defined in line 7 is another recursion call (this time in irregular syntax). The new value for `c` is to be: the result of running the same function on the the head of `a`, `-.a`, and with `1` added to `c`. We add `1` because we know that `a` must be a cell. Otherwise, we're asking for the number of cells in the rest of `-.a`.
483What makes this program is little harder to follow is that it has a recursion call within a recursion call. The first recursion expression on line 6 makes changes to two face values: `c`, the counter, and `a`, the input noun. The new value for `c` defined in line 7 is another recursion call (this time in irregular syntax). The new value for `c` is to be: the result of running the same function on the the head of `a`, `-.a`, and with `1` added to `c`. We add `1` because we know that `a` must be a cell. Otherwise, we're asking for the number of cells in the rest of `-.a`.
484
484
485−Once that new value for `c` is computed from the head of `a`, we're ready to check the tail of `a`, `+.a`. We'e already got everything we want from `-.a`, so we throw that away and replace `a` with `+.a`.
485+Once that new value for `c` is computed from the head of `a`, we're ready to check the tail of `a`, `+.a`. We've already got everything we want from `-.a`, so we throw that away and replace `a` with `+.a`.
486
486
487#### 'Samefringe' Exercise
487#### 'Samefringe' Exercise
488
488
docs/tutorials/hoon-ch2/hoon-ch2-6.umd+4−4
@@ -1,8 +1,8 @@
1:- :~ navhome/'/docs/'
1:- :~ navhome/'/docs/'
2 navuptwo/'true'
2 navuptwo/'true'
3 next/'true'
3 next/'true'
4− sort/'6'
4+ sort/'26'
5− title/'Structures and Complex Types'
5+ title/'2.6 Structures and Complex Types'
6 ==
6 ==
7;>
7;>
8
8
@@ -33,7 +33,7 @@ Structures play different roles in different code contexts. First, let's look a
33
33
34The `@`, `^`, and `[? *]` subexpressions have no effect at all on the final value produced.
34The `@`, `^`, and `[? *]` subexpressions have no effect at all on the final value produced.
35
35
36−It's important to understand that these casts don't affect the [runtime](https://en.wikipedia.org/wiki/Run_time_(program_lifecycle_phase)) semantics of a program at all. They affect only the compiler behavior at compile time. The compiler does these type-checks when compiling, but the resulting code has no value corresponding to the types above.
36+It's important to understand that these casts don't affect the [runtime](https://en.wikipedia.org/wiki/Run_time_(program_lifecycle_phase%29) semantics of a program at all. They affect only the compiler behavior at compile time. The compiler does these type-checks when compiling, but the resulting code has no value corresponding to the types above.
37
37
38Accordingly, the structures produced by the type subexpressions above aren't part of the program's runtime semantics. They are compile-time values only.
38Accordingly, the structures produced by the type subexpressions above aren't part of the program's runtime semantics. They are compile-time values only.
39
39
@@ -282,7 +282,7 @@ nest-fail
282
282
283### `$?` Define a Union
283### `$?` Define a Union
284
284
285−In set theory, the [union](https://en.wikipedia.org/wiki/Union_(set_theory)) of sets A and B is a set containing all members of both A and B. For example, the union of the set of even integers and the set of odd integers is the set of all integers.
285+In set theory, the [union](https://en.wikipedia.org/wiki/Union_(set_theory%29) of sets A and B is a set containing all members of both A and B. For example, the union of the set of even integers and the set of odd integers is the set of all integers.
286
286
287It's useful to be able to define a type that is the union of other types. The `$?` rune lets us do this. The `$?` takes a series of subexpressions, each of which must be a structure. The resulting type is the union of all types indicated in the expression. For example, `$?(%green %yellow %red)` is the union of the types indicated by `%green`, `%yellow`, and `%red`.
287It's useful to be able to define a type that is the union of other types. The `$?` rune lets us do this. The `$?` takes a series of subexpressions, each of which must be a structure. The resulting type is the union of all types indicated in the expression. For example, `$?(%green %yellow %red)` is the union of the types indicated by `%green`, `%yellow`, and `%red`.
288
288
docs/tutorials/hoon-ch2/hoon-ch2-7.umd+2−2
@@ -1,8 +1,8 @@
1:- :~ navhome/'/docs/'
1:- :~ navhome/'/docs/'
2 navuptwo/'true'
2 navuptwo/'true'
3 next/'true'
3 next/'true'
4− sort/'7'
4+ sort/'27'
5− title/'Cores'
5+ title/'2.7 Cores'
6 ==
6 ==
7;>
7;>
8
8
docs/tutorials/hoon-ch2/hoon-ch2-8.umd+4−4
@@ -1,8 +1,8 @@
1:- :~ navhome/'/docs/'
1:- :~ navhome/'/docs/'
2 navuptwo/'true'
2 navuptwo/'true'
3 next/'true'
3 next/'true'
4− sort/'8'
4+ sort/'28'
5− title/'Cores Again'
5+ title/'2.8 Cores Again'
6 ==
6 ==
7;>
7;>
8
8
@@ -151,7 +151,7 @@ Another way to cast for the type of the parent core of an arm is to use `_+>.$`.
151
151
152But what does it mean? First, the `_` indicates the irregular form of the `$_` rune. That is, `_+>.$` evaluates `+>.$` and produces a type from the resulting noun.
152But what does it mean? First, the `_` indicates the irregular form of the `$_` rune. That is, `_+>.$` evaluates `+>.$` and produces a type from the resulting noun.
153
153
154−What is `+>.$`? This is a wing of two limbs, `+>` and `$`. As you saw in section 1.4, `+>` is the lark syntax for `+7`, i.e., address space `7`. And `$` is the name of the lone arm in a gate. Whenever an arm name is used in a wing expression and isn't the left-most limb in the series, it evaluates to its parent core. The parent core of `$` is the gate itself.
154+What is `+>.$`? This is a wing of two limbs, `+>` and `$`. As you saw in [section 1.4](../../hoon-ch1/hoon-ch1-4), `+>` is the lark syntax for `+7`, i.e., address space `7`. And `$` is the name of the lone arm in a gate. Whenever an arm name is used in a wing expression and isn't the left-most limb in the series, it evaluates to its parent core. The parent core of `$` is the gate itself.
155
155
156Thus, `+>.$` evaluates to `+7` of the gate containing `$`. For our `plus` arm, the gate in question is the one defined by:
156Thus, `+>.$` evaluates to `+7` of the gate containing `$`. For our `plus` arm, the gate in question is the one defined by:
157
157
@@ -278,7 +278,7 @@ For each random number generation, the `rng` core has a different seed number.
278\/ \/
278\/ \/
279```
279```
280
280
281−`eny` is an environment value for [entropy](https://en.wikipedia.org/wiki/Entropy_(computing)). Its value changes every time it's evaluated. We can use `eny` to produce a seed value for `rng` and retry the `=^` expression from above:
281+`eny` is an environment value for [entropy](https://en.wikipedia.org/wiki/Entropy_(computing%29). Its value changes every time it's evaluated. We can use `eny` to produce a seed value for `rng` and retry the `=^` expression from above:
282
282
283```
283```
284> =rng ~(. og eny)
284> =rng ~(. og eny)
docs/tutorials/hoon-ch2/hoon-ch2-9.umd+3−3
@@ -1,12 +1,12 @@
1:- :~ navhome/'/docs/'
1:- :~ navhome/'/docs/'
2 navuptwo/'true'
2 navuptwo/'true'
3 next/'true'
3 next/'true'
4− sort/'9'
4+ sort/'29'
5− title/'Hoon Standard Library: Lists'
5+ title/'2.9 Standard Library: Lists'
6 ==
6 ==
7;>
7;>
8
8
9−# Hoon Standard Library: Lists
9+# Standard Library: Lists
10
10
11In this lesson we'll review what a list is and then cover many of the list-related functions in the Hoon standard library.
11In this lesson we'll review what a list is and then cover many of the list-related functions in the Hoon standard library.
12
12
docs/tutorials/internals.umd+2−2
@@ -35,7 +35,7 @@ for Unix.
35
35
36Here's a duct that was recently observed in the wild:
36Here's a duct that was recently observed in the wild:
37
37
38−````
38+```
39~[
39~[
40 /g/a/~zod/4_shell_terminal/u/time
40 /g/a/~zod/4_shell_terminal/u/time
41 /g/a/~zod/shell_terminal/u/child/4/main
41 /g/a/~zod/shell_terminal/u/child/4/main
@@ -43,7 +43,7 @@ Here's a duct that was recently observed in the wild:
43 /d/term-mess
43 /d/term-mess
44 //term/1
44 //term/1
45]
45]
46−````
46+```
47
47
48This is the duct the timer vane receives when "timer" sample app asks
48This is the duct the timer vane receives when "timer" sample app asks
49the timer vane to set a timer. This is also the duct over which the
49the timer vane to set a timer. This is also the duct over which the