on master help sign in
Merge pull request #447 from urbit/hoon-school
afe0511rmariani
concepts.udon+6−6
@@ -10,9 +10,9 @@
10
10
11The documents in this section are high-level introductions to the Urbit project and components thereof.
11The documents in this section are high-level introductions to the Urbit project and components thereof.
12
12
13−- [Arvo vs. Azimuth](/docs/introduction/arvo-vs-azimuth), a quick explanation of the two parallel systems that compose Urbit.
13+- [Arvo vs. Azimuth](/docs/concepts/arvo-vs-azimuth), a quick explanation of the two parallel systems that compose Urbit.
14−- [Technical Overview](/docs/introduction/technical-overview), a more in-depth description of the entire Urbit stack.
14+- [Technical Overview](/docs/concepts/technical-overview), a more in-depth description of the entire Urbit stack.
15−- [Contributing](/docs/introduction/contributing), a guide to getting involved with the Urbit project.
15+- [Contributing](/docs/concepts/contributing), a guide to getting involved with the Urbit project.
16−- [Community Tutorials](/docs/introduction/community-tutorials), a collection of unofficial but useful Urbit learning resources.
16+- [Community Tutorials](/docs/concepts/community-tutorials), a collection of unofficial but useful Urbit learning resources.
17−- [Source Code](/docs/introduction/source-code-overview), an explanation of Urbit's constituent GitHub repos.
17+- [Source Code](/docs/concepts/source-code-overview), an explanation of Urbit's constituent GitHub repos.
18−- [Galaxies, Stars, and Planets](/docs/introduction/galaxies-stars-and-planets), an explanation of the Urbit address-space hierarchy.
18+- [Galaxies, Stars, and Planets](/docs/concepts/galaxies-stars-and-planets), an explanation of the Urbit address-space hierarchy.
learn/hoon/hoon-tutorial/nouns.udon+13−5
@@ -12,7 +12,7 @@ In Urbit every piece of data is a noun. In order to understand Hoon one must fi
12
12
13## Noun Definition
13## Noun Definition
14
14
15−A *noun* is either an atom or a cell. An *atom* is an unsigned integer of any size. A *cell* is an [ordered pair](https://en.wikipedia.org/wiki/Ordered_pair) of nouns, usually indicated with square brackets around the nouns in question; i.e., `[a b]`, where `a` and `b` are nouns.
15+A *noun* is either an atom or a cell. An *atom* is a natural number ("unsigned integer" in computer lingo) of any size, including zero. A *cell* is an [ordered pair](https://en.wikipedia.org/wiki/Ordered_pair) of nouns, usually indicated with square brackets around the nouns in question; i.e., `[a b]`, where `a` and `b` are nouns.
16
16
17Here are some atoms:
17Here are some atoms:
18
18
@@ -121,7 +121,9 @@ As for why the dojo deleted your zero: it parses the command line as you type, a
121
121
122### Atom Auras
122### Atom Auras
123
123
124−Atoms 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. It answers the question: What type of information is this atom?
124+Atoms are nothing more than unsigned integers -- natural numbers -- but it's often useful to represent an atom in a different way. This is done with an *aura*. The aura of an atom is type meta-data used by Hoon to determine how to interpret that atom. It answers the question: What type of information is this atom?
125+
126+We use auras because data isn't always represented as a positive decimal number. Sometimes we want to represent data as binary, as text, or as a negative number. Auras allow us to to use such types of data _without changing the underlying atom_.
125
127
126We 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 a few atom auras.
128We 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 a few atom auras.
127
129
@@ -185,7 +187,7 @@ The `\`@\`` syntax is used to 'cast' a value to a raw atom, i.e., an atom withou
185
187
186#### Identities, Cords, and Terms
188#### Identities, Cords, and Terms
187
189
188−Urbit identities such as `~zod` and `~sorreg-namtyv` are also atoms with their own distinctive syntax:
190+Urbit identities such as `~zod` and `~sorreg-namtyv` are also atoms, but of the aura `@p`:
189
191
190```
192```
191> ~zod
193> ~zod
@@ -197,11 +199,17 @@ Urbit identities such as `~zod` and `~sorreg-namtyv` are also atoms with their o
197> `@`~zod
199> `@`~zod
1980
2000
199
201
202+> `@p`0
203+~zod
204+
200> `@`~sorreg-namtyv
205> `@`~sorreg-namtyv
2015.702.400
2065.702.400
207+
208+> `@p`5.702.400
209+~sorreg-namtyv
202```
210```
203
211
204−Hoon permits the use of atoms as strings. Strings that are encoded as atoms are called *cords*. The literal syntax of a cord is text inside a pair of single-quotes, e.g., `'Hello world!'`.
212+Hoon permits the use of atoms as strings. Strings that are encoded as atoms are called *cords*. Cords are of the aura `@t`. The literal syntax of a cord is text inside a pair of single-quotes, e.g., `'Hello world!'`.
205
213
206```
214```
207> 'Howdy!'
215> 'Howdy!'
@@ -217,7 +225,7 @@ Hoon permits the use of atoms as strings. Strings that are encoded as atoms are
21710.334.410.032.606.748.633.331.426.632
22510.334.410.032.606.748.633.331.426.632
218```
226```
219
227
220−Hoon also has *terms*. These are strings preceded with a `%` and made up of lower-case letters, numbers, and hyphens, i.e., 'kebab case'. The first character after the `%` must be a letter. For example, `%a`, `%hello`, `%this-is-kebab-case123`.
228+Hoon also has *terms*, of the aura `@tas`. Terms are constant values that are used to tag data using the type system. These are strings preceded with a `%` and made up of lower-case letters, numbers, and hyphens, i.e., 'kebab case'. The first character after the `%` must be a letter. For example, `%a`, `%hello`, `%this-is-kebab-case123`.
221
229
222```
230```
223> %howdy
231> %howdy
learn/hoon/workbook/caesar.udon+2−2
@@ -24,7 +24,7 @@ Right-shifted cipher: "ep opu hjwf xbz up bohfs"
24Note that the Caesar cipher is completely unsuitable for actually securing
24Note that the Caesar cipher is completely unsuitable for actually securing
25information. Implementing it in a program is just a fun exercise.
25information. Implementing it in a program is just a fun exercise.
26
26
27−### A Caesar Cipher In Hoon
27+## A Caesar Cipher In Hoon
28
28
29Below is a generator that performs a Caesar cipher on a tape. This example
29Below is a generator that performs a Caesar cipher on a tape. This example
30isn't the most compact implementation of such a cipher in Hoon, but it
30isn't the most compact implementation of such a cipher in Hoon, but it
@@ -111,7 +111,7 @@ nest-fail
111
111
112```
112```
113
113
114−##### Examining Our Code
114+### Examining Our Code
115
115
116Let's examine our `caesar.hoon` code piece by piece. We won't necessarily go
116Let's examine our `caesar.hoon` code piece by piece. We won't necessarily go
117in written order; instead, we'll cover code in the intuitive order of the
117in written order; instead, we'll cover code in the intuitive order of the
learn/hoon/workbook/list.udon+5−5
@@ -23,11 +23,11 @@ Below is a simple Hoon program that takes a single number `n` from the user as i
23$(count (add 1 count)) :: 8
23$(count (add 1 count)) :: 8
24```
24```
25
25
26−The easiest way to use such a program is to run it as a _generator_. Saving a file in the `/home/gen` directory of your ship allows you to run it from your ship's Dojo (command line) as a generator. Save the above code there as `list.udon`. Now you can run it in the Dojo as so:
26+The easiest way to use such a program is to run it as a _generator_. Saving a file in the `/home/gen` directory of your ship allows you to run it from your ship's Dojo (command line) as a generator. Save the above code there as `list.hoon`. Now you can run it in the Dojo as so:
27
27
28`~your-ship:> +list 5`
28`~your-ship:> +list 5`
29
29
30−Try it! You can choose any natural number to put after `+list`, but it can't be zero or blank. The `+` lets the Dojo know that it's looking for a generator with the name that follows.
30+Try it! You can choose any natural number to put after `+list`, but it can't be zero or blank. The `+` lets the Dojo know that it's looking for a generator with the name that follows. You don't write out the `.hoon` part of the file name when running it in the Dojo.
31
31
32But what do all these squiggly symbols in the program _do_? It probably isn't immediately clear. Let's go through each component of this code.
32But what do all these squiggly symbols in the program _do_? It probably isn't immediately clear. Let's go through each component of this code.
33
33
@@ -45,7 +45,7 @@ In our example program, we use comments with line numbers for convenient referen
45
45
46There's a few things going on in our first line. The first part of it, `|=`, is a kind of *rune*. Runes are the building blocks of all Hoon code, represented as a pair of non-alphanumeric ASCII characters. Runes form expressions; runes are used how keywords are used in other languages. In other words, all computations in Hoon ultimately require runes. Runes and other Hoon expressions are all separated from one another by either two spaces or a line break.
46There's a few things going on in our first line. The first part of it, `|=`, is a kind of *rune*. Runes are the building blocks of all Hoon code, represented as a pair of non-alphanumeric ASCII characters. Runes form expressions; runes are used how keywords are used in other languages. In other words, all computations in Hoon ultimately require runes. Runes and other Hoon expressions are all separated from one another by either two spaces or a line break.
47
47
48−All runes take a fixed number of "children." Children can themselves be runes with children, and Hoon programs work by chaining through these until a value -- not another rune -- is arrived at. Keep this scheme in mind when examining Hoon code.
48+All runes take a fixed number of "children." Children can themselves be runes with children, and Hoon programs work by chaining through these until a value -- not another rune -- is arrived at. For this reason, we very rarely need to close expressions. Keep this scheme in mind when examining Hoon code.
49
49
50The specific purpose of the `|=` rune is to create a *gate*. A gate is what would be called a function in other languages: it takes an input, performs a specified computation, and then produces an output.
50The specific purpose of the `|=` rune is to create a *gate*. A gate is what would be called a function in other languages: it takes an input, performs a specified computation, and then produces an output.
51
51
@@ -63,7 +63,7 @@ This line begins with the `=/` rune, which stores a value with a name and specif
63
63
64`count=@` (the first child) stores `1` (the second child) as `count` and as specifies that has the `@` type.
64`count=@` (the first child) stores `1` (the second child) as `count` and as specifies that has the `@` type.
65
65
66−We're using `count` to keep track of what numbers we're adding to the list we're building. We'll use it later in the program.
66+We're using `count` to keep track of what numbers we're including in the list we're building. We'll use it later in the program.
67
67
68### Line 3
68### Line 3
69
69
@@ -110,7 +110,7 @@ $(count (add 1 count))
110
110
111The above code is, once again, a compact way of writing a rune expression. All you need to know is that this line of code restarts the program at `|-`, except with the value stored in `count` incremented by 1. The construction of `(count (add 1 count))` tells the computer, "replace the value of count with count+1".
111The above code is, once again, a compact way of writing a rune expression. All you need to know is that this line of code restarts the program at `|-`, except with the value stored in `count` incremented by 1. The construction of `(count (add 1 count))` tells the computer, "replace the value of count with count+1".
112
112
113−You'll notice that we use an unfamiliar word here: `add`. Unlike `count` and `end`, `add` is not defined anywhere in our program. That's because it's a gate that's predefined in the Hoon *standard library*. The standard library is filled with pre-defined gates that are generally useful, and these gates can be used just like something that you defined in your own program.
113+You'll notice that we use an unfamiliar word here: `add`. Unlike `count` and `end`, `add` is not defined anywhere in our program. That's because it's a gate that's predefined in the Hoon *standard library*. The standard library is filled with pre-defined gates that are generally useful, and these gates can be used just like something that you defined in your own program. You can see this gate, and other mathematical operators, in [section 1a](/docs/reference/library/1a) of the standard-library documentation.
114
114
115## Explanation
115## Explanation
116
116
using.udon+1−1
@@ -6,7 +6,7 @@
6
6
7# Using
7# Using
8
8
9−This section contains guides to using your Urbit.
9+This section contains guides to using your urbit.
10
10
11- [Admin and Operation](admin) is a guide to the basic commands used to interact with your ship.
11- [Admin and Operation](admin) is a guide to the basic commands used to interact with your ship.
12- [Messaging](messaging) tells you how to use Talk, our chat system.
12- [Messaging](messaging) tells you how to use Talk, our chat system.