@@ -1,8 +1,8 @@
2navhome: /docs/
2navhome: /docs/
@@ -18,29 +18,30 @@ side of simple manual construction over high-octane FP.)
19A function that produces the list of primes less than or equal to
19A function that produces the list of primes less than or equal to
20its argument, an atom:
20its argument, an atom:
22−:gate thru/atom :: 1
23+|= thru/@ :: 1
23−:cast (list atom) :: 2
24+^- (list @) :: 2
24−:var field/(set atom) (silt (gulf 2 thru)) :: 3
25+=/ field/(set @) (silt (gulf 2 thru)) :: 3
25−:rap abet:main :: 4
26+=< abet:main :: 4
27++ abet :: 6
28++ abet :: 6
28 (sort (~(tap in field) ~) lth) :: 7
29 (sort (~(tap in field) ~) lth) :: 7
30++ main :: 9
31++ main :: 9
31− :var factor/atom 2 :: 10
32+ =/ factor/@ 2 :: 10
32− :loop :like ..main :: 11
33+ |- ^+ ..main :: 11
33− :if (gth (mul factor factor) thru) :: 12
34+ ?: (gth (mul factor factor) thru) :: 12
34 ..main :: 13
35 ..main :: 13
35− :moar(factor +(factor), ..main (reap factor)) :: 14
36+ $(factor +(factor), ..main (reap factor)) :: 14
37++ reap :: 16
38++ reap :: 16
38− :gate factor/atom :: 17
39+ |= factor/@ :: 17
39− :var count/atom (mul 2 factor) :: 18
40+ =/ count/@ (mul 2 factor) :: 18
40− :loop :like ..reap :: 19
41+ |- ^+ ..reap :: 19
41− :if (gth count thru) :: 20
42+ ?: (gth count thru) :: 20
42 ..reap :: 21
43 ..reap :: 21
43− :moar :: 22
44+ %= $ :: 22
44 count (add count factor) :: 23
45 count (add count factor) :: 23
45 field (~(del in field) count) :: 24
46 field (~(del in field) count) :: 24
@@ -50,9 +51,9 @@ its argument, an atom:
50## `sieve`: explanation
51## `sieve`: explanation
53−:gate thru/atom :: 1
54+|= thru/@ :: 1
54−:cast (list atom) :: 2
55+^- (list @) :: 2
55−:var field/(set atom) (silt (gulf 2 thru)) :: 3
56+=/ field/(set @) (silt (gulf 2 thru)) :: 3
58Line `1`: we are building a gate (function) whose sample
59Line `1`: we are building a gate (function) whose sample
@@ -67,13 +68,13 @@ list of atoms.
68Line `4`: below, we introduce a core which does our work. With
69Line `4`: below, we introduce a core which does our work. With
69reverse flow, we compute `main` on this core, then `abet` on the
70reverse flow, we compute `main` on this core, then `abet` on the
70−product of `main`. (`abet:main` means `:rap(abet main)`.)
71+product of `main`. (`abet:main` means `=<(abet main)`.)
72The core is a state machine; `main` produces the core itself,
73The core is a state machine; `main` produces the core itself,
73with the computation completed. `abet` then extracts the result.
74with the computation completed. `abet` then extracts the result.
77++ abet :: 6
78++ abet :: 6
78 (sort (~(tap in field) ~) lth) :: 7
79 (sort (~(tap in field) ~) lth) :: 7
@@ -90,8 +91,8 @@ list in ascending order with `lth` (less-than).
92++ main :: 9
93++ main :: 9
93− :var factor/atom 2 :: 10
94+ =/ factor/@ 2 :: 10
94− :loop :like ..main :: 11
95+ |- ^+ ..main :: 11
97Line `9`: the `main` arm, which performs the main calculation.
98Line `9`: the `main` arm, which performs the main calculation.
@@ -103,9 +104,9 @@ Line `11`: we start a loop. The product of the loop is cast to
103`..main`, which is the core we're in (`+1.main`).
104`..main`, which is the core we're in (`+1.main`).
106− :if (gth (mul factor factor) thru) :: 12
107+ ?: (gth (mul factor factor) thru) :: 12
107 ..main :: 13
108 ..main :: 13
108− :moar(factor +(factor), ..main (reap factor)) :: 14
109+ $(factor +(factor), ..main (reap factor)) :: 14
111Lines `12` and `13`: we terminate the loop, returning `..main`,
112Lines `12` and `13`: we terminate the loop, returning `..main`,
@@ -116,8 +117,8 @@ replacing the core with a version sieved by `reap`.
118++ reap :: 16
119++ reap :: 16
119− :gate factor/atom :: 17
120+ |= factor/@ :: 17
120− :var count/atom (mul 2 factor) :: 18
121+ =/ count/@ (mul 2 factor) :: 18
123Lines `16` and `17`: the `reap` arm, which produces a gate that
124Lines `16` and `17`: the `reap` arm, which produces a gate that
@@ -128,10 +129,10 @@ Line `18`: we declare a variable `count`, an atom, with the
128initial value `(mul 2 factor)`.
129initial value `(mul 2 factor)`.
131− :loop :like ..reap :: 19
132+ |- ^+ ..reap :: 19
132− :if (gth count thru) :: 20
133+ ?: (gth count thru) :: 20
133 ..reap :: 21
134 ..reap :: 21
134− :moar :: 22
135+ %= $ :: 22
135 count (add count factor) :: 23
136 count (add count factor) :: 23
136 field (~(del in field) count) :: 24
137 field (~(del in field) count) :: 24
@@ -147,9 +148,7 @@ multiple of `factor`, and deleting it from `field`.
148## `sieve`: code in kernel style
149## `sieve`: code in kernel style
150−Finally, the same code transliterated into runes (and in a more
151−concise "kernel" style).
151+Finally, the same code in a more concise "kernel" style.
155^- (list @)
154^- (list @)
@@ -165,7 +164,7 @@ concise "kernel" style).
165 $(fac +(fac), ..main (reap fac))
164 $(fac +(fac), ..main (reap fac))
168− |= fac/atom
167+ |= fac/@
169 =+ cot=(mul 2 fac)
168 =+ cot=(mul 2 fac)
170 |- ^+ ..reap
169 |- ^+ ..reap
171 ?: (gth cot top)
170 ?: (gth cot top)
@@ -181,65 +180,65 @@ state, producing a list of game actions. Events are tic-tac-toe
181moves (`move)`; actions are tic-tac-toe results (`fact`).
180moves (`move)`; actions are tic-tac-toe results (`fact`).
184−:rap :gate feed/(list move) :: 1
183+=< |= feed/(list move) :: 1
185− :new game/game :: 2
184+ =| game/game :: 2
186− :loop :cast (list fact) :: 3
185+ |- ^- (list fact) :: 3
187− :ifno feed ~ :: 4
186+ ?~ feed ~ :: 4
188− :sip this/(unit fact) :: 5
187+ =^ this/(unit fact) :: 5
189− game :: 6
188+ game :: 6
190− (~(do go game) i.feed) :: 7
189+ (~(do go game) i.feed) :: 7
191− :var rest/(list fact) :moar(feed t.feed) :: 8
190+ =/ rest/(list fact) $(feed t.feed) :: 8
192− :ifno(this rest [u.this rest]) :: 9
191+ ?~(this rest [u.this rest]) :: 9
194−:per :core :: 11
193+=> |% :: 11
195− ++ side atom :: 12
194+ ++ side @ :: 12
196− ++ spot {x/atom y/atom} :: 13
195+ ++ spot {x/@ y/@} :: 13
197− ++ fact :book {$tie $~} :: 14
196+ ++ fact $% {$tie $~} :: 14
198− {$win p/cord} :: 15
197+ {$win p/cord} :: 15
199− == :: 16
198+ == :: 16
200− ++ move :book {$x p/spot} :: 17
199+ ++ move $% {$x p/spot} :: 17
201− {$o p/spot} :: 18
200+ {$o p/spot} :: 18
202− {$z $~} :: 19
201+ {$z $~} :: 19
203− == :: 20
202+ == :: 20
204− ++ game :bank w/? :: 21
203+ ++ game $: w/? :: 21
205− a/side :: 22
204+ a/side :: 22
206− z/side :: 23
205+ z/side :: 23
207− == :: 24
206+ == :: 24
208− -- :: 25
207+ -- :: 25
209−:core :: 26
208+|% :: 26
210++ bo :: 27
209++ bo :: 27
211− :door half/side :: 28
210+ |_ half/side :: 28
212− ++ bit :gate(a/atom =(1 (cut 0 [a 1] half))) :: 29
211+ ++ bit |=(a/@ =(1 (cut 0 [a 1] half))) :: 29
213− ++ off :gate(a/spot (add x.a (mul 3 y.a))) :: 30
212+ ++ off |=(a/spot (add x.a (mul 3 y.a))) :: 30
214− ++ get :gate(a/spot (bit (off a))) :: 31
213+ ++ get |=(a/spot (bit (off a))) :: 31
215− ++ set :gate(a/spot (con half (bex (off a)))) :: 32
214+ ++ set |=(a/spot (con half (bex (off a)))) :: 32
216− ++ win :calt lien :: 33
215+ ++ win %+ lien :: 33
217 (rip 4 0wl04h0.4A0Aw.4A00s.0e070) :: 34
216 (rip 4 0wl04h0.4A0Aw.4A00s.0e070) :: 34
218− :gate(a/atom =(a (dis a half))) :: 35
217+ |=(a/@ =(a (dis a half))) :: 35
220++ go :: 37
219++ go :: 37
221− :door game/game :: 38
220+ |_ game/game :: 38
222 ++ do :: 39
221 ++ do :: 39
223− :gate act/move :: 40
222+ |= act/move :: 40
224− :cast {(unit fact) ^game} :: 41
223+ ^- {(unit fact) ^game} :: 41
225− :case act :: 42
224+ ?- act :: 42
226− {$x *} :sure(w.game ~(mo on p.act)) :: 43
225+ {$x *} ?>(w.game ~(mo on p.act)) :: 43
227− {$o *} :deny(w.game ~(mo on p.act)) :: 44
226+ {$o *} ?<(w.game ~(mo on p.act)) :: 44
228 {$z *} [~ nu] :: 45
227 {$z *} [~ nu] :: 45
231− ++ nu :like(game [& 0 0]) :: 48
230+ ++ nu ^+(game [& 0 0]) :: 48
232 ++ on :: 49
231 ++ on :: 49
233− :door here/spot :: 50
232+ |_ here/spot :: 50
234− ++ is :or (~(get bo a.game) here) :: 51
233+ ++ is ?| (~(get bo a.game) here) :: 51
235− (~(get bo z.game) here) :: 52
234+ (~(get bo z.game) here) :: 52
236− == :: 53
235+ == :: 53
237− ++ mo :cast {(unit fact) ^game} :: 54
236+ ++ mo ^- {(unit fact) ^game} :: 54
238− :deny is :: 55
237+ ?< is :: 55
239− :var next/side (~(set bo a.game) here) :: 56
238+ =/ next/side (~(set bo a.game) here) :: 56
240− :if ~(win bo next) :: 57
239+ ?: ~(win bo next) :: 57
241− [[~ %win ?:(w.game %x %o)] nu] :: 58
240+ [[~ %win ?:(w.game %x %o)] nu] :: 58
242− [~ game(w !w.game, a z.game, z next)] :: 59
241+ [~ game(w !w.game, a z.game, z next)] :: 59
@@ -248,10 +247,10 @@ moves (`move)`; actions are tic-tac-toe results (`fact`).
248### `toe`: explanation
247### `toe`: explanation
251−:rap :gate feed/(list move) :: 1
250+=< |= feed/(list move) :: 1
252− :new game/game :: 2
251+ =| game/game :: 2
253− :loop :cast (list fact) :: 3
252+ |- ^- (list fact) :: 3
254− :ifno feed ~ :: 4
253+ ?~ feed ~ :: 4
257Line `1` wraps a conclusion around a stack of cores. The cores
256Line `1` wraps a conclusion around a stack of cores. The cores
@@ -268,7 +267,7 @@ Line `3` enters a loop producing a list of game events, `fact`.
268Line `4` produces nil, `~`, if `feed` is empty.
267Line `4` produces nil, `~`, if `feed` is empty.
271− :sip this/(unit fact) :: 5
270+ =^ this/(unit fact) :: 5
272 game :: 6
271 game :: 6
273 (~(do go game) i.feed) :: 7
272 (~(do go game) i.feed) :: 7
@@ -277,12 +276,12 @@ Lines `5` through `7` apply the move. We open a `go` core on the
277current game state, produce a `do` gate, and call that gate on
276current game state, produce a `do` gate, and call that gate on
278the move. The product of the `do` gate is a pair; the head is
277the move. The product of the `do` gate is a pair; the head is
279`(unit fact)`, either `~` or `[~ fact]`; the tail is a new
278`(unit fact)`, either `~` or `[~ fact]`; the tail is a new
280−`game`. The `:sip` twig declares the head as a new variable,
279+`game`. The `=^` hoon declares the head as a new variable,
281`this`; it modifies the subject by setting `game` to the tail.
280`this`; it modifies the subject by setting `game` to the tail.
284− :var rest/(list fact) :moar(feed t.feed) :: 8
283+ =/ rest/(list fact) $(feed t.feed) :: 8
285− :ifno(this rest [u.this rest]) :: 9
284+ ?~(this rest [u.this rest]) :: 9
288Line `8` declares a new variable, `rest`, which is all the facts
287Line `8` declares a new variable, `rest`, which is all the facts
@@ -292,9 +291,9 @@ generated by the moves in `t.feed`, the tail of the move list.
292prepends the new fact to `rest`.
291prepends the new fact to `rest`.
295−:per :core :: 11
294+=> |% :: 11
296− ++ side atom :: 12
295+ ++ side @ :: 12
297− ++ spot {x/atom y/atom} :: 13
296+ ++ spot {x/@ y/@} :: 13
300Line `11` wraps a library core around a data structure core, a
299Line `11` wraps a library core around a data structure core, a
@@ -308,9 +307,9 @@ A side is a half of the board, as a marked/unmarked bitfield.
308Line `13` defines the `spot` mold, a 2D coordinate.
307Line `13` defines the `spot` mold, a 2D coordinate.
311− ++ fact :book {$tie $~} :: 14
310+ ++ fact $% {$tie $~} :: 14
312− {$win p/cord} :: 15
311+ {$win p/cord} :: 15
313− == :: 16
312+ == :: 16
316Lines `14` to `16` define the `fact` mold, a game event (i.e.,
315Lines `14` to `16` define the `fact` mold, a game event (i.e.,
@@ -319,21 +318,21 @@ output action), as a book (tagged union). There are two forms of
319(reporting that `'X'` or `'O'` won a game.
318(reporting that `'X'` or `'O'` won a game.
322− ++ move :book {$x p/spot} :: 17
321+ ++ move $% {$x p/spot} :: 17
323− {$o p/spot} :: 18
322+ {$o p/spot} :: 18
324− {$z $~} :: 19
323+ {$z $~} :: 19
325− == :: 20
324+ == :: 20
328Lines `17` to `20` define the `move` mold, a game move. This is
327Lines `17` to `20` define the `move` mold, a game move. This is
329either `[%x spot]`, `[%o spot]`, or `[%z ~]` to reset the board.
328either `[%x spot]`, `[%o spot]`, or `[%z ~]` to reset the board.
332− ++ game :bank w/? :: 21
331+ ++ game $: w/? :: 21
333− a/side :: 22
332+ a/side :: 22
334− z/side :: 23
333+ z/side :: 23
335− == :: 24
334+ == :: 24
336− -- :: 25
335+ -- :: 25
339Lines `21` to `23` define the `game` mold, the game state. This
338Lines `21` to `23` define the `game` mold, the game state. This
@@ -342,13 +341,13 @@ side; and `w`, which is `&` (yes) if `a` is X and `b` is O; `|`
342otherwise. (Obviously, we swap `a` and `z` on every move.)
341otherwise. (Obviously, we swap `a` and `z` on every move.)
345−:core :: 26
344+|% :: 26
346++ bo :: 27
345++ bo :: 27
347− :door half/side :: 28
346+ |_ half/side :: 28
348− ++ bit :gate(a/atom =(1 (cut 0 [a 1] half))) :: 29
347+ ++ bit |=(a/@ =(1 (cut 0 [a 1] half))) :: 29
349− ++ off :gate(a/spot (add x.a (mul 3 y.a))) :: 30
348+ ++ off |=(a/spot (add x.a (mul 3 y.a))) :: 30
350− ++ get :gate(a/spot (bit (off a))) :: 31
349+ ++ get |=(a/spot (bit (off a))) :: 31
351− ++ set :gate(a/spot (con half (bex (off a)))) :: 32
350+ ++ set |=(a/spot (con half (bex (off a)))) :: 32
354Line `26` introduces the library core, which contains the doors
353Line `26` introduces the library core, which contains the doors
@@ -369,9 +368,9 @@ bit at a `spot` set. It works by ORing (`con`) `half` with the
369binary exponent (`bex`) of the offset (`off`) of the spot.
368binary exponent (`bex`) of the offset (`off`) of the spot.
372− ++ win :calt lien :: 33
371+ ++ win %+ lien :: 33
373 (rip 4 0wl04h0.4A0Aw.4A00s.0e070) :: 34
372 (rip 4 0wl04h0.4A0Aw.4A00s.0e070) :: 34
374− :gate(a/atom =(a (dis a half))) :: 35
373+ |=(a/@ =(a (dis a half))) :: 35
@@ -383,10 +382,10 @@ of which must equal itself when ANDed (`dis`) with `half`.
385++ go :: 37
384++ go :: 37
386− :door game/game :: 38
385+ |_ game/game :: 38
387 ++ do :: 39
386 ++ do :: 39
388− :gate act/move :: 40
387+ |= act/move :: 40
389− :cast {(unit fact) ^game} :: 41
388+ ^- {(unit fact) ^game} :: 41
392Lines `37` to `38` begin the `go` core, a door around a `game`.
391Lines `37` to `38` begin the `go` core, a door around a `game`.
@@ -398,9 +397,9 @@ move. The product is cast to a pair of `(unit fact)` and a new
398game state, written `^game` to skip to the second binding.
397game state, written `^game` to skip to the second binding.
401− :case act :: 42
400+ ?- act :: 42
402− {$x *} :sure(w.game ~(mo on p.act)) :: 43
401+ {$x *} ?>(w.game ~(mo on p.act)) :: 43
403− {$o *} :deny(w.game ~(mo on p.act)) :: 44
402+ {$o *} ?<(w.game ~(mo on p.act)) :: 44
404 {$z *} [~ nu] :: 45
403 {$z *} [~ nu] :: 45
@@ -412,12 +411,12 @@ the `mo` door to apply the move. If it's a `%z` move, we clear
412the board.
411the board.
415− ++ nu :like(game [& 0 0]) :: 48
414+ ++ nu ^+(game [& 0 0]) :: 48
416 ++ on :: 49
415 ++ on :: 49
417− :door here/spot :: 50
416+ |_ here/spot :: 50
418− ++ is :or (~(get bo a.game) here) :: 51
417+ ++ is ?| (~(get bo a.game) here) :: 51
419− (~(get bo z.game) here) :: 52
418+ (~(get bo z.game) here) :: 52
420− == :: 53
419+ == :: 53
423Line `48` is the `nu` arm, which produces a blank game state.
422Line `48` is the `nu` arm, which produces a blank game state.
@@ -427,16 +426,16 @@ Lines `49` to `50` begin the `on` door, a door around `here`, a
427game state, we have multiple computed attributes (`is` and `mo`)
426game state, we have multiple computed attributes (`is` and `mo`)
428against the combination of game state and coordinate.
427against the combination of game state and coordinate.
430−Lines `51` to `53` define the `is` arm, which is `&` (yes) iff
429+Lines `51` to `53` define the `is` arm, which is `&` (yes) if
431either `a` or `z` has played `here`.
430either `a` or `z` has played `here`.
434− ++ mo :cast {(unit fact) ^game} :: 54
433+ ++ mo ^- {(unit fact) ^game} :: 54
435− :deny is :: 55
434+ ?< is :: 55
436− :var next/side (~(set bo a.game) here) :: 56
435+ =/ next/side (~(set bo a.game) here) :: 56
437− :if ~(win bo next) :: 57
436+ ?: ~(win bo next) :: 57
438− [[~ %win ?:(w.game %x %o)] nu] :: 58
437+ [[~ %win ?:(w.game %x %o)] nu] :: 58
439− [~ game(w !w.game, a z.game, z next)] :: 59
438+ [~ game(w !w.game, a z.game, z next)] :: 59
@@ -487,13 +486,13 @@ side `z`, and replaces `z` with `next`.
489 |_ haf/side
488 |_ haf/side
490− ++ bit |=(a/atom =(1 (cut 0 [a 1] haf)))
489+ ++ bit |=(a/@ =(1 (cut 0 [a 1] haf)))
491 ++ get |=(a/spot (bit (off a)))
490 ++ get |=(a/spot (bit (off a)))
492 ++ off |=(a/spot (add x.a (mul 3 y.a)))
491 ++ off |=(a/spot (add x.a (mul 3 y.a)))
493 ++ set |=(a/spot (con haf (bex (off a))))
492 ++ set |=(a/spot (con haf (bex (off a))))
494 ++ win %+ lien
493 ++ win %+ lien
495 (rip 4 0wl04h0.4A0Aw.4A00s.0e070)
494 (rip 4 0wl04h0.4A0Aw.4A00s.0e070)
496− |=(a/atom =(a (dis a haf)))
495+ |=(a/@ =(a (dis a haf)))
499 |_ mag/game
498 |_ mag/game
@@ -510,9 +509,9 @@ side `z`, and replaces `z` with `next`.
511 =| her/spot
510 =| her/spot
513− ++ is ?| (~(get bo a.mag) her)
512+ ++ is ?| (~(get bo a.mag) her)
514− (~(get bo z.mag) her)
513+ (~(get bo z.mag) her)
516 ++ mo ^- {(unit fact) game}
515 ++ mo ^- {(unit fact) game}
518 =+ next=(~(set bo a.mag) her)
517 =+ next=(~(set bo a.mag) her)
@@ -563,28 +562,28 @@ side `z`, and replaces `z` with `next`.
566−++ tree |* a/gate :: binary tree
565+++ tree |* a/gate :: binary tree
567 $@($~ {n/a l/(tree a) r/(tree a)}) ::
566 $@($~ {n/a l/(tree a) r/(tree a)}) ::
568++ trap |*(a/_* _|?(*a)) :: makes perfect sense
567++ trap |*(a/_* _|?(*a)) :: makes perfect sense
569−++ trel |* {a/gate b/gate c/gate} :: just a triple
568+++ trel |* {a/gate b/gate c/gate} :: just a triple
570 {p/a q/b r/c} ::
569 {p/a q/b r/c} ::
571++ each |* {a/gate b/gate} :: either a or b
570++ each |* {a/gate b/gate} :: either a or b
572 $%({$& p/a} {$| p/b}) :: a default
571 $%({$& p/a} {$| p/b}) :: a default
574−++ qual |* {a/gate b/gate c/gate d/gate} :: just a quadruple
573+++ qual |* {a/gate b/gate c/gate d/gate} :: just a quadruple
575 {p/a q/b r/c s/d} ::
574 {p/a q/b r/c s/d} ::
576−++ pair |*({a/gate b/gate} {p/a q/b}) :: just a pair
575+++ pair |*({a/gate b/gate} {p/a q/b}) :: just a pair
577−++ quid |*({a/gate b/*} {a _b}) :: for =^
576+++ quid |*({a/gate b/*} {a _b}) :: for =^
578−++ quip |*({a/gate b/*} {(list a) _b}) :: for =^
577+++ quip |*({a/gate b/*} {(list a) _b}) :: for =^
579−++ unit |* a/gate :: maybe
578+++ unit |* a/gate :: maybe
580 $@($~ {$~ u/a}) ::
579 $@($~ {$~ u/a}) ::
581−++ list |* a/gate :: null-term list
580+++ list |* a/gate :: null-term list
582 $@($~ {i/a t/(list a)}) ::
581 $@($~ {i/a t/(list a)}) ::
583−++ lone |*(a/gate p/a) :: just one thing
582+++ lone |*(a/gate p/a) :: just one thing
587−++ map |* {a/gate b/gate} :: associative tree
586+++ map |* {a/gate b/gate} :: associative tree
588 $@($~ {n/{p/a q/b} l/(map a b) r/(map a b)}) ::
587 $@($~ {n/{p/a q/b} l/(map a b) r/(map a b)}) ::
589++ qeu |* a/gate :: queue
588++ qeu |* a/gate :: queue
590 $@($~ {n/a l/(qeu a) r/(qeu a)}) ::
589 $@($~ {n/a l/(qeu a) r/(qeu a)}) ::