on master help sign in
typo
commit5fcbd652aa2c559e837710b27e61e7a7bab8a7a7 authorGalen Wolfe-Pauly <root@office-for.com> dateTue 19 Jul 2016, 11:50 (10 years ago) parentd6be9a1
1 file changed+13−14
docs/byte/2.md+13−14
docs/byte/2.md+13−14
@@ -1,10 +1,9 @@
11---
22navhome: /docs
33sort: 3
4−next: false
54title: Subject-oriented programming
65---
7−
6+
87# Urbyte 2: subject-oriented programming
98
109Thanks for reading Urbytes 0 and 1! In Urbyte 2, we'll take
@@ -37,7 +36,7 @@ are expressions.
3736
3837(The dojo is not the only command-line app on your Urbit. By
3938default there is one other, `:talk`. Since you're on a fakezod,
40−you can only talk to yourself. If you accidentally press `^X`,
39+you can only talk to yourself. If you accidentally press `^X`,
4140it will put you into `:talk`; press `^X` again to switch back.)
4241
4342### Dojo variables
@@ -96,7 +95,7 @@ In Hoon or any "subject-oriented" language, an expression is
9695executed against one normal value, the *subject*. In Hoon, of
9796course, the subject is a noun.
9897
99−## First experiments
98+## First experiments
10099
101100Up to now, we've only built constants. By definition, a constant
102101doesn't use the subject.
@@ -142,20 +141,20 @@ The most basic way to access the subject is *tree geometry*.
142141Every noun is a binary tree; every noun in the tree has a number
143142which is its address. The root of the tree is `1`; if the
144143address of a cell is `n`, its head is `2n` and its tail is
145−`2n+1`.
144+`2n+1`.
146145
147146A picture might help::
148147```
149148 1
150149 / \
151− 2 3
150+ 2 3
152151 / \ / \
153152 4 5 6 7
154153 / \
155154 14 15
156155```
157156
158−The syntax for a fragment of the subject at a tree address, or
157+The syntax for a fragment of the subject at a tree address, or
159158*axis*, is just `+axis`. So:
160159
161160```
@@ -184,7 +183,7 @@ For example, suppose our tree looked like:
184183```
185184 1
186185 / \
187− x=2 3
186+ x=2 3
188187 / \
189188 y=6 z=7
190189 / \
@@ -298,7 +297,7 @@ Above, we mutated our first noun with the flashy `a(+7 x=z:a)`.
298297
299298Of course we are not really "modifying" a noun. Hoon is a pure
300299language. We are making an edited copy. `a(+7 x=z:a)` means "a
301−copy of `a`, with limb `+7` replaced by the product of `x=z:a`."
300+copy of `a`, with limb `+7` replaced by the product of `x=z:a`."
302301
303302We can edit multiple (disjoint) wings in one expression:
304303
@@ -349,7 +348,7 @@ found, we search into the payload of the core.
349348When you type these examples, make sure you get the number of
350349spaces exactly right. Hoon syntax is not whitespace-sensitive
351350in general, except that "one space" is always a different token
352−from "two or more spaces."
351+from "two or more spaces."
353352
354353```
355354> ? x:a
@@ -384,7 +383,7 @@ Let's look at the core itself:
384383
385384```
386385> b
387−<2.spy {x/@ud y/{p/$foo q/@rs r/@dr} x/@ux}>
386+<2.spy {x/@ud y/{p/$foo q/@rs r/@dr} x/@ux}>
388387
389388> ? +2:b
390389 *
@@ -396,11 +395,11 @@ Let's look at the core itself:
396395```
397396
398397When we print `b`, or any core, we see that typed noun printing
399−can't be an invertible function in Hoon.
398+can't be an invertible function in Hoon.
400399
401400We actually can read the battery (with `+2:b` above), but it's
402−just Nock code, not typed data. `<2.spy>` tells us the battery
403−has two arms and hashes to the three-letter code `spy`.
401+just Nock code, not typed data. `<2.spy>` tells us the battery
402+has two arms and hashes to the three-letter code `spy`.
404403
405404When printing a full core, we don't even print the payload data,
406405just its type. But our `+3:b` confirms the `[battery payload]`