on master help sign in
updated links, added example-prefix
79d793bHenry Ault
docs/programming/system/basic.md+9−9
@@ -47,7 +47,7 @@ Switch desks to run commands from the `%examples` desk:
47
47
48Run an example:
48Run an example:
49
49
50− ~fintud-macrep:dojo> +euler1
50+ ~fintud-macrep:dojo> +examples-euler1
51 233.168
51 233.168
52
52
53## Euler 1
53## Euler 1
@@ -62,14 +62,14 @@ Find the sum of all the multiples of 3 or 5 below 1000.
62```
62```
63
63
64Here is the hoon solution (which should be in your pier directory
64Here is the hoon solution (which should be in your pier directory
65−under `/examples/gen/euler1.hoon`):
65+under `/gen/examples/euler1`):
66
66
67```
67```
68:: project euler 1
68:: project euler 1
69:: https://projecteuler.net/problem=1
69:: https://projecteuler.net/problem=1
70−:: run in dojo with +euler1
70+:: run in dojo with +examples-euler1
71::
71::
72−:::: /hoon/euler1/gen
72+:::: /hoon/euler1/examples/gen
73 ::
73 ::
74:- %say |= *
74:- %say |= *
75:- %noun
75:- %noun
@@ -108,7 +108,7 @@ Hoon is not generally whitespace sensitive, but we do have two
108different kinds of whitespace: a single space and a gap, which
108different kinds of whitespace: a single space and a gap, which
109is two or more spaces or a linebreak. Tabs are taboo. Do not
109is two or more spaces or a linebreak. Tabs are taboo. Do not
110use them. Really. For a more detailed explanation of when to
110use them. Really. For a more detailed explanation of when to
111−use spaces vs. gaps, see the [syntax section](docs/programming/core/twig/syntax) before the first
111+use spaces vs. gaps, see the syntax section before the first
112excercises.
112excercises.
113</blockquote>
113</blockquote>
114
114
@@ -127,7 +127,7 @@ more detail later.
127
127
128### How to form expressions
128### How to form expressions
129
129
130−Hoon does not use reserved words to form expressions. (We did recently implement an alternative keyword syntax, which is not covered here. For more information, see the [syntax section](docs/programming/core/twig/syntax)). Instead,
130+Hoon does not use reserved words to form expressions. (We did recently implement an alternative keyword syntax, which is not covered here. For more information, see the [syntax section](/docs/programming/core/twig/syntax/). Instead,
131expressions are formed with runes--diagraphs of two
131expressions are formed with runes--diagraphs of two
132ascii symbols. Each rune takes a specific number of
132ascii symbols. Each rune takes a specific number of
133children--either expressions formed by other runes or literals
133children--either expressions formed by other runes or literals
@@ -195,7 +195,7 @@ Let's step into each of the three arms within our core.
195`|=` produces a function, much like a lambda in lisp. It takes two children:
195`|=` produces a function, much like a lambda in lisp. It takes two children:
196
196
197- A set of argument(s). In this case our argument set only
197- A set of argument(s). In this case our argument set only
198− contains one: `a` which is required to be an atom or natural
198+ contains one: `a`, which is required to be an atom or natural
199 number, denoted by `@`.
199 number, denoted by `@`.
200
200
201- The body of the function itself, which is executed when the
201- The body of the function itself, which is executed when the
@@ -254,7 +254,7 @@ recur.
254
254
255Please tweak your code to complete the following excercises.
255Please tweak your code to complete the following excercises.
256
256
257−There are a few runes and some syntax that we have yet to cover that
257+There are a few runes and some syntaxes that we have yet to cover that
258you will need to complete the excercises below. For these, please
258you will need to complete the excercises below. For these, please
259refer to our cheatsheat at the bottom.
259refer to our cheatsheat at the bottom.
260
260
@@ -262,7 +262,7 @@ refer to our cheatsheat at the bottom.
262
262
263- Change `++sum` to accept two variables, `a` and `b`. Pass `a`
263- Change `++sum` to accept two variables, `a` and `b`. Pass `a`
264 to three and `b` to five. Then run the code with `a` set to
264 to three and `b` to five. Then run the code with `a` set to
265− `1.000` and b set to `2.000`.
265+ `1.000` and ` q` set to `2.000`.
266
266
267- Check if this new result is under one thousand. If it is,
267- Check if this new result is under one thousand. If it is,
268 return the string 'result is less than one thousand'. If not,
268 return the string 'result is less than one thousand'. If not,
docs/programming/system/generators.md+22−20
@@ -4,6 +4,8 @@ sort: 8
4title: Using Generators with Apps
4title: Using Generators with Apps
5---
5---
6
6
7+# Generators
8+
7Up until now we've poked apps directly. This requires the user
9Up until now we've poked apps directly. This requires the user
8to specify the mark, and it requires the app to accept the
10to specify the mark, and it requires the app to accept the
9arguments in a way that's convenient for users to input. This is
11arguments in a way that's convenient for users to input. This is
@@ -12,7 +14,7 @@ the "plumbing" way to interact with apps. Generators are the
12`|merge`, there are no marks in sight.
14`|merge`, there are no marks in sight.
13
15
14We've used generators before, back in [Basic
16We've used generators before, back in [Basic
15−Operation](http://urbit.org/docs/user/basic). At that point, we just used the generators
17+Operation](/docs/user/basic). At that point, we just used the generators
16to produce values -- we didn't pipe their results into apps. In
18to produce values -- we didn't pipe their results into apps. In
17the dojo cast, the role of a generator is to take a list of
19the dojo cast, the role of a generator is to take a list of
18arguments and produce a value, which is often, though not always,
20arguments and produce a value, which is often, though not always,
@@ -52,22 +54,22 @@ abbreviated to `:my-app|my-generator <args>`. Because most
52built-in commands are generators for the `:hood` app,
54built-in commands are generators for the `:hood` app,
53`:hood|generator <args>` can be shortened to `|generator <args>`.
55`:hood|generator <args>` can be shortened to `|generator <args>`.
54
56
55−Let's write a generator for a modified version of `:pong` from
57+Let's write a generator for a modified version of `:examples-pong` from
56−the chapter on [Network Messages](http://urbit.org/docs/user/network). Recall that `:pong`
58+the chapter on [Network Messages](/docs/programming/system/network). Recall that `:examples-pong`
57takes an urbit address, which is of mark `urbit`, and sends that
59takes an urbit address, which is of mark `urbit`, and sends that
58urbit the message `'howdy'`. First--without a generator--let's
60urbit the message `'howdy'`. First--without a generator--let's
59−make `:ping` that does the same, except that it lets the user
61+make `:examples-ping` that does the same, except that it lets the user
60optionally specify the message as well.
62optionally specify the message as well.
61
63
62We'll need a new mark for our arguments. Let's call it
64We'll need a new mark for our arguments. Let's call it
63−`ping-message`.
65+`examples-ping-message`.
64
66
65<blockquote class="blockquote">
67<blockquote class="blockquote">
66For app-specific marks, it's good style to prefix the name of
68For app-specific marks, it's good style to prefix the name of
67the mark with the name of the app. Since many apps have
69the mark with the name of the app. Since many apps have
68several such marks, subdirectories in `/mar` are rendered as
70several such marks, subdirectories in `/mar` are rendered as
69`-`, so that `ping-message` is written in
71`-`, so that `ping-message` is written in
70−(`/mar/ping/message.hoon`).
72+(/mar/examples/ping/message.hoon).
71</blockquote>
73</blockquote>
72
74
73```
75```
@@ -139,7 +141,7 @@ several such marks, subdirectories in `/mar` are rendered as
139--
141--
140```
142```
141
143
142−The app can easily be modified to use this (`/app/ping.hoon`):
144+The app can easily be modified to use this (`/app/examples/ping.hoon`):
143
145
144```
146```
145::
147::
@@ -178,27 +180,27 @@ The app can easily be modified to use this (`/app/ping.hoon`):
178Now we can run this with:
180Now we can run this with:
179
181
180```
182```
181−~fintud-macrep:dojo> |start %ping
183+~fintud-macrep:dojo> |start %examples-ping
182>=
184>=
183−~fintud-macrep:dojo> :ping &ping-message [~sampel-sipnym 'heyya']
185+~fintud-macrep:dojo> :examples-ping &ping-message [~sampel-sipnym 'heyya']
184>=
186>=
185```
187```
186
188
187−And on `~sampel-sipnym`, assuming it's running `:ping` as well,
189+And on `~sampel-sipnym`, assuming it's running `:examples-ping` as well,
188we see `[%receiving 'heyya']`.
190we see `[%receiving 'heyya']`.
189
191
190This is an annoying way to invoke the app, though. The `[]` are
192This is an annoying way to invoke the app, though. The `[]` are
191mandatory, and optional arguments are hard. Let's make a
193mandatory, and optional arguments are hard. Let's make a
192−generator, `+send` to make everything nicer. Since it's specific
194+generator, `+examples-send` to make everything nicer. Since it's specific
193−to `:ping`, let's put it in `/gen/ping/send.hoon`:
195+to `:examples-ping`, let's put it in `/gen/examples/ping/send.hoon`:
194
196
195```
197```
196:- %say
198:- %say
197|= {^ {{to/@p message/?($~ {text/@t $~})} $~}
199|= {^ {{to/@p message/?($~ {text/@t $~})} $~}
198−[%ping-message to ?~(message 'howdy' text.message)]
200+[%examples-ping-message to ?~(message 'howdy' text.message)]
199```
201```
200
202
201−A couple of new things here. Firstly, `message/?($~ {text=@t $~})`
203+A couple of new things here. Firstly, `message/?($~ {text/@t $~})`
202should be read as "the message is either null or a pair of text
204should be read as "the message is either null or a pair of text
203and null". Generator argument lists are always null-terminated,
205and null". Generator argument lists are always null-terminated,
204which makes it convenient to accept lists in tail position (which
206which makes it convenient to accept lists in tail position (which
@@ -232,9 +234,9 @@ would complain that it doesn't know whether `message` has
232This is run as follows:
234This is run as follows:
233
235
234```
236```
235−~fintud-macrep:dojo> :ping|send ~sampel-sipnym
237+~fintud-macrep:dojo> :examples-ping|send ~sampel-sipnym
236>=
238>=
237−~fintud-macrep:dojo> :ping|send ~sampel-sipnym 'how do you do'
239+~fintud-macrep:dojo> :examples-ping|send ~sampel-sipnym 'how do you do'
238>=
240>=
239```
241```
240
242
@@ -243,8 +245,8 @@ Which causes `~sampel-sipnym` to print `[%receiving 'howdy']` and
243
245
244**Exercises**:
246**Exercises**:
245
247
246−- Create a generator for `:sum` from [State](state) so that
248+- Create a generator for `:examples-sum` from [State](state) so that
247− you can run `:sum|add 5` to add numbers to it.
249+ you can run `:examples-sum|add 5` to add numbers to it.
248
250
249−- Create a generator for `:click` from [Web Apps](web-apps) so
251+- Create a generator for `:examples-click` from [Web Apps](web-apps) so
250− that you can run `:click|poke` to poke it.
252+ that you can run `:examplesclick|poke` to poke it.
docs/programming/system/http.md+37−26
@@ -14,48 +14,59 @@ service periodically and print out an error when the response
14code isn't 2xx. Here's `app/up.hoon`:
14code isn't 2xx. Here's `app/up.hoon`:
15
15
16```
16```
17+:: Up-ness monitor. Accepts atom url, 'on', or 'off'
18+::
19+:::: /hoon/up/examples/app
20+ ::
17/? 314
21/? 314
18|%
22|%
19++ move {bone card}
23++ move {bone card}
20++ card
24++ card
21− $% {%them wire (unit hiss)}
25+ $% {$hiss wire $~ $httr {$purl p/purl}}
22− {%wait wire @da}
26+ {$wait wire @da}
27+ ==
28+++ action
29+ $% {$on $~} :: enable polling('on')
30+ {$off $~} :: disable polling('off)
31+ {$target p/cord} :: set poll target('http://...')
23 ==
32 ==
24--
33--
25−|_ {hid/bowl on/_| in-progress=_| target/@t}
34+|_ {hid/bowl on/_| in-progress/_| target/@t}
26−++ poke-cord
35+++ poke-atom
27− |= url/@t
36+ |= url-or-command/@t ^- (quip move +>)
28− ^- {(list move) _+>.$}
37+ =+ ^- act/action
38+ ?: ?=($on url-or-command) [%on ~]
29− ?: =('off' url)
39+ ?: ?=($off url-or-command) [%off ~]
30− [~ +>.$(on |)]
40+ [%target url-or-command]
31− ?: =('on' url)
41+ ?- -.act
32− :_ +>.$(on &, in-progress &)
42+ $target [~ +>.$(target p.act)]
43+ $off [~ +>.$(on |)]
44+ $on
33− ?: |(on in-progress)
45+ :- ?: |(on in-progress) ~
34− ~
35− [ost.hid %them /request ~ (need (epur target)) %get ~ ~]~
46+ [ost.hid %hiss /request ~ %httr %purl (need (epur target))]~
36− [~ +>.$(target url)]
47+ +>.$(on &, in-progress &)
37−++ thou-request
48+ ==
49+++ sigh-httr
38 |= {wir/wire code/@ud headers/mess body/(unit octs)}
50 |= {wir/wire code/@ud headers/mess body/(unit octs)}
51+ ~& 'arrive here'
39 ^- {(list move) _+>.$}
52 ^- {(list move) _+>.$}
40 ?: &((gte code 200) (lth code 300))
53 ?: &((gte code 200) (lth code 300))
41 ~& [%all-is-well code]
54 ~& [%all-is-well code]
42 :_ +>.$
55 :_ +>.$
43− ?: on
44− [ost.hid %wait /timer (add ~s10 now.hid)]~
56+ [ost.hid %wait /timer (add ~s10 now.hid)]~
45− ~
46 ~& [%we-have-a-problem code]
57 ~& [%we-have-a-problem code]
47 ~& [%headers headers]
58 ~& [%headers headers]
48 ~& [%body body]
59 ~& [%body body]
49 :_ +>.$
60 :_ +>.$
50− ?: on
51− [ost.hid %wait /timer (add ~s10 now.hid)]~
61+ [ost.hid %wait /timer (add ~s10 now.hid)]~
52− ~
53++ wake-timer
62++ wake-timer
54− |= {wir/wire ~}
63+ |= {wir/wire $~} ^- (quip move +>)
55 ?: on
64 ?: on
56 :_ +>.$
65 :_ +>.$
57− [ost.hid %them /request ~ (need (epur target)) %get ~ ~]~
66+ [ost.hid %hiss /request ~ %httr %purl (need (epur target))]~
58 [~ +>.$(in-progress |)]
67 [~ +>.$(in-progress |)]
68+::
69+++ prep ~& target _`. ::
59--
70--
60```
71```
61
72
@@ -173,14 +184,14 @@ Let's try it out:
173```
184```
174~fintud-macrep:dojo> |start %up
185~fintud-macrep:dojo> |start %up
175>=
186>=
176−~fintud-macrep:dojo> :up &cord 'http://www.google.com'
187+~fintud-macrep:dojo> :examples-up &cord 'http://www.google.com'
177>=
188>=
178[%all-is-well 200]
189[%all-is-well 200]
179[%all-is-well 200]
190[%all-is-well 200]
180−~fintud-macrep:dojo> :up &cord 'http://example.com'
191+~fintud-macrep:dojo> :examples-up &cord 'http://example.com'
181>=
192>=
182[%all-is-well 200]
193[%all-is-well 200]
183−~fintud-macrep:dojo> :up &cord 'http://google.com'
194+~fintud-macrep:dojo> :examples-up &cord 'http://google.com'
184>=
195>=
185[%we-have-a-problem 301]
196[%we-have-a-problem 301]
186[ %headers
197[ %headers
docs/programming/system/network.md+19−18
@@ -10,12 +10,12 @@ Now we've learned enough hoon to do more interesting things.
10Let's get our planets to talk to each other.
10Let's get our planets to talk to each other.
11
11
12All we've written up until now are just shell
12All we've written up until now are just shell
13−commands that produce a value and then disappear. To listen for and receive messages from other planets, we'll need an app--let's look at a very simple one:
13+commands that produce a value and then disappear. To listen for and receive messages from other planets, we'll need an app. Let's look at a very simple one:
14
14
15```
15```
16:: There is no love that is not an echo
16:: There is no love that is not an echo
17::
17::
18−:::: /hoon/echo/app
18+:::: /hoon/echo/examples/app
19 ::
19 ::
20/? 314
20/? 314
21!:
21!:
@@ -37,10 +37,10 @@ with the following commands:
37```
37```
38~fintud-macrep:dojo> |start %echo
38~fintud-macrep:dojo> |start %echo
39>=
39>=
40−~fintud-macrep:dojo> :echo 5
40+~fintud-macrep:dojo> :examples-echo 5
41[%argument 5]
41[%argument 5]
42>=
42>=
43−~fintud-macrep:dojo> :echo [1 2]
43+~fintud-macrep:dojo> :examples-echo [1 2]
44[%argument [1 2]]
44[%argument [1 2]]
45>=
45>=
46```
46```
@@ -90,7 +90,7 @@ app state is stored. It'll become clear why this is later on,
90but for now pretend that `+>.$` is a magic invocation that means
90but for now pretend that `+>.$` is a magic invocation that means
91"app state".
91"app state".
92
92
93−Let's look at another example. Say we want to only accept a
93+Let's look at another example (edit your code in `/app/examples/echo/hoon` to reflect the code below). Say we want to only accept a
94number, and then print out the square of that number.
94number, and then print out the square of that number.
95
95
96```
96```
@@ -108,7 +108,7 @@ number, and then print out the square of that number.
108
108
109A few things have changed. Firstly, we no longer accept
109A few things have changed. Firstly, we no longer accept
110arbitrary nouns because we can only square atoms (integers, in
110arbitrary nouns because we can only square atoms (integers, in
111−this case an unsigned one). Thus, our argument is now `arg=@`.
111+this case an unsigned one). Thus, our argument is now `arg/@`.
112Secondly, it's `++poke-atom` rather than `++poke-noun`.
112Secondly, it's `++poke-atom` rather than `++poke-noun`.
113
113
114# Intro to marks
114# Intro to marks
@@ -136,9 +136,9 @@ commands:
136```
136```
137~fintud-macrep:dojo> |start %square
137~fintud-macrep:dojo> |start %square
138>=
138>=
139−~fintud-macrep:dojo> :square 6
139+~fintud-macrep:dojo> :examples-square 6
140gall: %square: no poke arm for noun
140gall: %square: no poke arm for noun
141−~fintud-macrep:dojo> :square &atom 6
141+~fintud-macrep:dojo> :examples-square &atom 6
142[%square 36]
142[%square 36]
143>=
143>=
144```
144```
@@ -149,14 +149,14 @@ gall: %square: no poke arm for noun
149Marks are powerful, and they're the backbone of urbit's data
149Marks are powerful, and they're the backbone of urbit's data
150pipeline, so we'll be getting quite used to them.
150pipeline, so we'll be getting quite used to them.
151
151
152−**Exercises**:
152+**Exercise**:
153
153
154- Write an app that computes fizzbuzz on its input (as in the
154- Write an app that computes fizzbuzz on its input (as in the
155 previous section).
155 previous section).
156
156
157# Sending a message to another ship
157# Sending a message to another ship
158
158
159−Let's write our first network message! Here's `/app/pong.hoon`:
159+Let's write our first network message! Here's `/app/examples/pong.hoon`:
160
160
161```
161```
162/? 314
162/? 314
@@ -184,15 +184,15 @@ Let's write our first network message! Here's `/app/pong.hoon`:
184Run it with these commands:
184Run it with these commands:
185
185
186```
186```
187−~fintud-macrep:dojo> |start %pong
187+~fintud-macrep:dojo> |start %examples-pong
188>=
188>=
189−~fintud-macrep:dojo> :pong &urbit ~sampel-sipnym
189+~fintud-macrep:dojo> :pong &examples-urbit ~sampel-sipnym
190>=
190>=
191```
191```
192
192
193Replace `~sampel-sipnym` with another urbit. The easiest thing to
193Replace `~sampel-sipnym` with another urbit. The easiest thing to
194do is to start a [moon](), a sub-identity of your urbit. Don't
194do is to start a [moon](), a sub-identity of your urbit. Don't
195−forget to start the `%pong` app on that urbit too. You should
195+forget to start the `%examples-pong` app on that urbit too. You should
196see, on the foreign urbit, this output:
196see, on the foreign urbit, this output:
197
197
198```
198```
@@ -230,21 +230,22 @@ The general form of a move is
230
230
231-arvo part---->
231-arvo part---->
232`[bone term wire *]`
232`[bone term wire *]`
233+
233− >-app/vane-specific part of move
234+------------------------->app/vane-specific part of move
234
235
235Or, in pseudo-code:
236Or, in pseudo-code:
236
237
237`["cause" sys-call/action tack-new-layer-on-cause action-specific
238`["cause" sys-call/action tack-new-layer-on-cause action-specific
238information]`
239information]`
239
240
240−Let's walk through each of these elements step by step
241+Let's walk through each of these elements step by step.
241
242
242#### Bones ("cause")
243#### Bones ("cause")
243
244
244If you look up `++bone` in `hoon.hoon`, you'll see that it's a
245If you look up `++bone` in `hoon.hoon`, you'll see that it's a
245number (`@ud`), and that it's an opaque reference to a duct.
246number (`@ud`), and that it's an opaque reference to a duct.
246−`++duct` in hoon.hoon is a list of `wire`s, where `wire` is an
247+`++duct` in hoon.hoon is a list of `wire`s, where `++wire` is an
247−alias for `path`. `++path` is a list of `span`s, which are ASCII
248+alias for `++path`. `++path` is a list of `++span`s, which are ASCII
248text. Thus, a duct is a list of paths, and a bone is an opaque
249text. Thus, a duct is a list of paths, and a bone is an opaque
249reference to it (in the same way that a Unix file
250reference to it (in the same way that a Unix file
250descriptor is an opaque reference to a file structure). Thus, to
251descriptor is an opaque reference to a file structure). Thus, to
@@ -331,7 +332,7 @@ anything with this information right now, but we could.
331- Extend either of the apps in the first two exercises to accept
332- Extend either of the apps in the first two exercises to accept
332 input over the network in the same way as `pong`.
333 input over the network in the same way as `pong`.
333
334
334−- Modify `pong` to print out a message when it receives acknowledgement.
335+- Modify `examples-pong` to print out a message when it receives acknowledgement.
335
336
336- Write two apps, `even` and `odd`. When you pass an atom to
337- Write two apps, `even` and `odd`. When you pass an atom to
337 `even`, check whether it's even. If so, divide it by two and
338 `even`, check whether it's even. If so, divide it by two and
docs/programming/system/state.md+11−9
@@ -4,11 +4,13 @@ sort: 4
4title: State
4title: State
5---
5---
6
6
7+# State
8+
7In the last section we built a few small apps that sent moves.
9In the last section we built a few small apps that sent moves.
8These apps were entirely stateless, however. Most useful apps
10These apps were entirely stateless, however. Most useful apps
9require some amount of state. Let's build a trivial stateful
11require some amount of state. Let's build a trivial stateful
10app. It'll keep a running the sum of all the atoms we poke it with.
12app. It'll keep a running the sum of all the atoms we poke it with.
11−Here's `app/sum.hoon`:
13+Here's `app/examples/sum.hoon`:
12
14
13```
15```
14/? 314
16/? 314
@@ -24,16 +26,16 @@ Here's `app/sum.hoon`:
24--
26--
25```
27```
26
28
27−We can start it with `|start %sum`, and then run it:
29+We can start it with `|start %examples-sum`, and then run it:
28
30
29```
31```
30−~fintud-macrep:dojo> :sum &atom 5
32+~fintud-macrep:dojo> :examples-sum &atom 5
31[%so-far 5]
33[%so-far 5]
32>=
34>=
33−~fintud-macrep:dojo> :sum &atom 2
35+~fintud-macrep:dojo> :examples-sum &atom 2
34[%so-far 7]
36[%so-far 7]
35>=
37>=
36−~fintud-macrep:dojo> :sum &atom 15
38+~fintud-macrep:dojo> :examples-sum &atom 15
37[%so-far 22]
39[%so-far 22]
38>=
40>=
39```
41```
@@ -93,17 +95,17 @@ through the hassle of having to set up and write to a database.
93
95
94**Exercises**:
96**Exercises**:
95
97
96−- Modify `:sum` to reset the counter when you poke it with zero.
98+- Modify `:examples-sum` to reset the counter when you poke it with zero.
97
99
98- Write an app that prints out the previous value you poked it
100- Write an app that prints out the previous value you poked it
99 with. Sample output:
101 with. Sample output:
100
102
101```
103```
102−~fintud-macrep:dojo> :last 7
104+~fintud-macrep:dojo> :examples-last 7
103[%last 0]
105[%last 0]
104>=
106>=
105−~fintud-macrep:dojo> :last [1 2 3]
107+~fintud-macrep:dojo> :examples-last [1 2 3]
106[%last 7]
108[%last 7]
107>=
109>=
108−~fintud-macrep:dojo> :last 'howdy'
110+~fintud-macrep:dojo> :examples-last 'howdy'
109[%last [1 2 3]]
111[%last [1 2 3]]
docs/programming/system/subject.md+2−3
@@ -22,8 +22,7 @@ noun (`*`). Its second child is the remainder of the program.
22
22
23Similarly, the rest of the program is a cell of the literal
23Similarly, the rest of the program is a cell of the literal
24`%noun`, which tells the shell that we're producing a value of
24`%noun`, which tells the shell that we're producing a value of
25−type `noun`, and the second child contains the code that we run
26−to actually produce our value of the type `noun`.
25+type `noun`, and the code that we run to actually produce our value of the type `noun`.
27
26
28`=<` is a rune that takes two children. The second child is the
27`=<` is a rune that takes two children. The second child is the
29context against which we run the first child. So in this case, we
28context against which we run the first child. So in this case, we
@@ -102,4 +101,4 @@ Cheatsheet:
102 ~]`
101 ~]`
103- `gte` tests whether `a` is greater than or equal to `b`.
102- `gte` tests whether `a` is greater than or equal to `b`.
104- `mod` runs the modulo operation on two atoms.
103- `mod` runs the modulo operation on two atoms.
105−- See the [basic math section]() for more info.
104+- See the basic math section in `/arvo/hoon.hoon` for more info.
docs/programming/system/subscriptions.md+24−24
@@ -10,8 +10,8 @@ more often we want to subscribe to updates from another app. You
10could build a subscription model out of one-way pokes, but it's
10could build a subscription model out of one-way pokes, but it's
11such a common pattern that it's built into arvo.
11such a common pattern that it's built into arvo.
12
12
13−Let's take a look at two apps, `:source` and `:sink`. First,
13+Let's take a look at two apps, `:examples-source` and `:examples-sink`. First,
14−`:source`:
14+`:examples-source`:
15
15
16```
16```
17/? 314
17/? 314
@@ -34,7 +34,7 @@ Let's take a look at two apps, `:source` and `:sink`. First,
34--
34--
35```
35```
36
36
37−And secondly, `:sink`:
37+And secondly, `:examples-sink`:
38
38
39```
39```
40/? 314
40/? 314
@@ -117,40 +117,40 @@ Cheat sheet:
117Here's some sample output of the two working together:
117Here's some sample output of the two working together:
118
118
119```
119```
120−~fintud-macrep:dojo> |start %source
120+~fintud-macrep:dojo> |start %examples-source
121>=
121>=
122−~fintud-macrep:dojo> |start %sink
122+~fintud-macrep:dojo> |start %examples-sink
123>=
123>=
124−~fintud-macrep:dojo> :sink %on
124+~fintud-macrep:dojo> :examples-sink %on
125[%subscribed-to pax=/the-path]
125[%subscribed-to pax=/the-path]
126%successfully-subscribed]
126%successfully-subscribed]
127>=
127>=
128−~fintud-macrep:dojo> :source 5
128+~fintud-macrep:dojo> :examples-source 5
129[%received-data 5]
129[%received-data 5]
130>=
130>=
131−~fintud-macrep:dojo> :sink %off
131+~fintud-macrep:dojo> :examples-sink %off
132>=
132>=
133−~fintud-macrep:dojo> :source 6
133+~fintud-macrep:dojo> :examples-source 6
134>=
134>=
135−~fintud-macrep:dojo> :sink %on
135+~fintud-macrep:dojo> :examples-sink %on
136[%subscribed-to pax=/the-path]
136[%subscribed-to pax=/the-path]
137%successfully-subscribed]
137%successfully-subscribed]
138>=
138>=
139−~fintud-macrep:dojo> :source 7
139+~fintud-macrep:dojo> :examples-source 7
140[%received-data 7]
140[%received-data 7]
141>=
141>=
142```
142```
143
143
144−###:source
144+###:examples-source
145
145
146Hopefully you can get a sense for what's happening here. When we
146Hopefully you can get a sense for what's happening here. When we
147−poke `:sink` with `%on`, `:sink` subscribes to `:source`, and so
147+poke `:examples-sink` with `%on`, `:examples-sink` subscribes to `:examples-source`, and so
148−whenever we poke `:source`, `:sink` gets the update and prints it
148+whenever we poke `:examples-source`, `:examples-sink` gets the update and prints it
149−out. Then we unsubscribe by poking `:sink` with `%off`, and
149+out. Then we unsubscribe by poking `:examples-sink` with `%off`, and
150−`:sink` stops getting updates. We then resubscribe.
150+`:examples-sink` stops getting updates. We then resubscribe.
151
151
152There's a fair bit going on in this code. Let's look at
152There's a fair bit going on in this code. Let's look at
153−`:source` first.
153+`:examples-source` first.
154
154
155Our definition of `move` is fairly specific, since we're only
155Our definition of `move` is fairly specific, since we're only
156going to sending one kind of move. The `%diff` move is a
156going to sending one kind of move. The `%diff` move is a
@@ -205,12 +205,12 @@ that provides bone `o` with this subscription update: `[%noun
205arg]`". This is fairly dense code, but what it's doing is
205arg]`". This is fairly dense code, but what it's doing is
206straightforward.
206straightforward.
207
207
208−###:sink
208+###:examples-sink
209
209
210−`:source` should now make sense. `:sink` is a little longer,
210+`:examples-source` should now make sense. `:examples-sink` is a little longer,
211but not much more complicated.
211but not much more complicated.
212
212
213−In `:sink`, our definition of of `++move` is different. All
213+In `:examples-sink`, our definition of of `++move` is different. All
214moves start with a `bone`, and we conventionally refer to the
214moves start with a `bone`, and we conventionally refer to the
215second half as the "card", so that we can say a move is an action
215second half as the "card", so that we can say a move is an action
216that sends a card along a bone.
216that sends a card along a bone.
@@ -225,13 +225,13 @@ this, because its semantics are to cancel any subscriptions
225coming over this duct. If your bone and wire are the same as
225coming over this duct. If your bone and wire are the same as
226when you subscribed, then the cancellation will happen correctly.
226when you subscribed, then the cancellation will happen correctly.
227
227
228−The only state we need for `:sink` is a boolean to indicate whether
228+The only state we need for `:examples-sink` is a boolean to indicate whether
229−we're already subscribed to `:source`. We use `available/?`,
229+we're already subscribed to `:examples-source`. We use `available/?`,
230where `?` is the sign of type boolean (similar to `*`, `@`) (which defaults to true).
230where `?` is the sign of type boolean (similar to `*`, `@`) (which defaults to true).
231
231
232In `++poke-noun` we check our input to see both if it's `%on` and
232In `++poke-noun` we check our input to see both if it's `%on` and
233we're available. If so, we produce the move to subscribe to
233we're available. If so, we produce the move to subscribe to
234−`:source`:
234+`:examples-source`:
235
235
236```
236```
237[ost %peer /subscribe [our %source] /the-path]
237[ost %peer /subscribe [our %source] /the-path]
@@ -241,7 +241,7 @@ Also, we set available to false (`|`) with `+>.$(available |)`.
241
241
242Otherwise, if our input is `%off` and we're already subscribed
242Otherwise, if our input is `%off` and we're already subscribed
243(i.e. `available` is false), then we unsubscribe from
243(i.e. `available` is false), then we unsubscribe from
244−`:source`:
244+`:examples-source`:
245
245
246```
246```
247[ost %pull /subscribe [our %source] ~]
247[ost %pull /subscribe [our %source] ~]