on master help sign in
Purged the sin of (add 1 a) from gates doc
commit9e93e5f114a9a6371947caa4013091f795771d10 authorDavid Kerschner <dkerschner@hcoop.net> dateWed 8 May 2019, 12:21 (7 years ago) parenta7c6419
1 file changed+3−3
learn/hoon/hoon-tutorial/gates.udon+3−3
learn/hoon/hoon-tutorial/gates.udon+3−3
@@ -55,7 +55,7 @@ Like all arms, `$` is computed with its parent core as the subject. When `$` is
5555Let's make a gate that takes any unsigned integer (i.e., an atom) as its sample and returns that value plus one as the product. To do this we'll use the `|=` rune. We'll bind this gate to the face `inc` for 'increment':
5656
5757```
58−> =inc |=(a=@ (add 1 a))
58+> =inc |=(a=@ +(a))
5959
6060> (inc 1)
61612
@@ -71,13 +71,13 @@ The gate works as promised -- it takes any number `n` and returns `n + 1`. Let'
7171
7272### The `|=` Rune
7373
74−We typically use the `|=` rune to create a gate. In the expression above the `|=` is immediately followed by a set of parentheses containing two subexpressions: `a=@` and `(add 1 a)`. The first defines the gate's sample (input value type), and the second defines the gate's product (value).
74+We typically use the `|=` rune to create a gate. In the expression above the `|=` is immediately followed by a set of parentheses containing two subexpressions: `a=@` and `+(a)`. The first defines the gate's sample (input value type), and the second defines the gate's product (value).
7575
7676When we used the `|%` rune in the last lesson we didn't use parentheses because we were writing in "tall form" syntax, whereas here we are writing in "flat form" syntax. (The latter uses parentheses and is more suitable for shorter snippets of code.) We'll explain these concepts more thoroughly in lesson 2.2.
7777
7878In the example gate above, `inc`, the sample is defined by `a=@`. This means that the sample is defined as an atom, `@`, meaning that the gate will take as input anything of that type. The sample is given the face `a`. With the face it's easier to refer to the sample in later code, if desired.
7979
80−In `inc`, the product is defined by `(add 1 a)`. There's not much to it -- it returns the value of `a + 1`!
80+In `inc`, the product is defined by `+(a)`. There's not much to it -- it returns the value of `a + 1`!
8181
8282The second subexpression after the `|=` rune is used to build the gate's `$` arm. That's where all the computations go.
8383