on master help sign in
merge changes
commitb8b8932d54d6a9cb96ce611c9eaf37046193b25f authorDavid Kerschner <dkerschner@hcoop.net> dateFri 11 Oct 2019, 11:18 (7 years ago) parentfdbef63eab26ff
63 files changed+492−25409
learn/hoon/hoon-tutorial/behn.md+94 reference/arvo-glossary.md+4−4 reference/hoon-errors.md+9−11 reference/hoon-expressions/rune/bar.md+60−60 reference/hoon-expressions/rune/buc.md+8−8 reference/hoon-expressions/rune/cen.md+61−61 reference/hoon-expressions/rune/ket.md+16−16 reference/hoon-expressions/rune/tis.md+27−27 reference/hoon-expressions/rune/wut.md+27−27 reference/library/1a.md−680 reference/library/1b.md+1−1 reference/library/1c.md+12−12 reference/library/2a.md−449 reference/library/2b.md−1293 reference/library/2c.md+23−23 reference/library/2d.md+4−4 reference/library/2e.md+4−4 reference/library/2f.md+6−6 reference/library/2g.md−105 reference/library/2h.md+17−17 reference/library/2i.md+24−24 reference/library/2j.md−272 reference/library/2k.md−399 reference/library/2l.md−111 reference/library/2m.md−308 reference/library/2n.md−427 reference/library/2o.md+5−5 reference/library/2p.md−242 reference/library/2q.md+11−11 reference/library/3a.md−858 reference/library/3b.md−5889 reference/library/3c.md−649 reference/library/3d.md+15−15 reference/library/3e.md−9 reference/library/3f.md+17−17 reference/library/3g.md+13−13 reference/library/4a.md−217 reference/library/4b.md−994 reference/library/4c.md−364 reference/library/4d.md−100 reference/library/4e.md−471 reference/library/4f.md−1195 reference/library/4g.md−179 reference/library/4h.md+33−33 reference/library/4i.md−1054 reference/library/4j.md−1656 reference/library/4k.md−276 reference/library/4l.md−608 reference/library/4m.md−434 reference/library/4n.md−447 reference/library/4o.md−782 reference/library/5a.md−7 reference/library/5b.md−7 reference/library/5c.md−7 reference/library/5d.md−7 reference/library/5e.md−7 reference/library/5f.md−176 reference/library/5g.md−7 reference/library/_index.md−1733 reference/library/table-of-contents.md−1730 reference/library/zuse.md−10 tutorials/arvo/glossary.md−850 tutorials/nock/implementations.md+1−1
learn/hoon/hoon-tutorial/behn.mdnew file+94
@@ -0,0 +1,94 @@
1++++
2+title = "Behn"
3+weight = 0
4+template = "doc.html"
5++++
6+
7+Behn is an Arvo vane that acts as a simple timer. It allows vanes and applications to set timer events, which are managed in a simple priority queue.
8+
9+An app or vane can make a request to Behn to be informed when a specified amount of time has elapsed. Behn then produces effects to begin a unix timer for that request. The unix timer informs Behn after the specified time has elapses, which then informs the requestee. There is no guarantee that the requestee will be informed of the elapsed timer at the precise moment it requested, or even that it will be close. The only guarantee is that the requester will be informed at some point after the allotted time has passed.
10+
11+## Types
12+
13+We review here some of the commonly used types in the Behn vane as found in `behn.hoon`.
14+
15+### `timer`
16+```
17++$ timer [date=@da =duct]
18+```
19+
20+A `timer` consists of a `@da` (an absolute date at which the timer will go off) and a `duct` (representing the causal stack that began the timer). As part of its state, `Behn` keeps track of a list of `timer`s.
21+
22+### `behn-state`
23+
24+```
25++$ behn-state
26+ $: timers=(list timer)
27+ unix-duct=duct
28+ next-wake=(unit @da)
29+ drips=drip-manager
30+ ==
31+```
32+
33+We see that a `behn-state` is a list of all `timers` that `Behn` is currently keeping track of. `unix-duct` is Behn's link to the unix timer. `next-wake` is the next time that `Behn` is supposed to inform a requestee that the specified timer has elapsed. We will ignore `drips` for the purpose of this tutorial.
34+
35+### `move`
36+
37+Arvo vanes communicate via `moves`:
38+```
39++$ move [p=duct q=(wind note gift:able)]
40+```
41+A `duct` is a call stack, which is a list of `path`s that represent a step in a causal chain of events. A `wind` is a kernel action. See the following arm from `arvo.hoon`:
42+
43+```
44+++ wind :: new kernel action
45+ |* [a=mold b=mold] :: forward+reverse
46+ $% [%pass p=path q=a] :: advance
47+ [%slip p=a] :: lateral
48+ [%give p=b] :: retreat
49+ ==
50+```
51+
52+Here we see that `wind` produces a wet gate that takes in two molds, which for the `move` type for Behn are `note`s and `gift`s. When a vane needs to request something of another vane, it `%pass`es a `note`. When a vane produces a result that was requested, it `%gives` a `gift` to the caller.
53+
54+## Internal arms
55+
56+The following arms are part of the `event-core` of Behn, which are essentially the internal functions of the Behn vane that are not directly accessible to other vanes and applications. We will not review all of them here, we only list some of most important ones.
57+
58+### ++set-unix-wake
59+This arm is what Behn uses to tell the unix timer when to `%wake` Behn.
60+
61+### ++set-timer
62+This arm is a dry gate that takes in a `timer` and adds it to the list of `timer`s in the `state`. ``++set-timer`` automatically places the new `timer` in chronological order, so that the timer at the front of the list of `timer`s is the `timer` that will expire the soonest.
63+
64+### ++wait
65+```
66+++ wait |=(date=@da set-unix-wake(timers.state (set-timer [date duct])))
67+```
68+This arm is called when Behn is `%pass`ed a `note` telling Behn to `%wait`. This adds a `timer` to the list of `timer`s in the `state` and correspondingly tells the unix timer to tell Behn when the specified time has passed.
69+
70+### ++rest
71+```
72+++ rest |=(date=@da set-unix-wake(timers.state (unset-timer [date duct])))
73+```
74+This undoes a `++wait` operation. That is, `++rest` removes a timer from the list of `timer`s.
75+
76+### ++wake
77+This arm is ultimately called by the unix timer to let Behn know that a previously specified amount of time has elapsed.
78+
79+### ++born
80+
81+```
82+++ born set-unix-wake(next-wake.state ~, unix-duct.state duct)
83+```
84+This arm is called when Behn is first launched. It gives Behn a `duct` to the unix timer and initializes the `behn-state` with the face `state` with a null list of `timer`s.
85+
86+## External interface
87+
88+Arvo talks to Behn via four arms, `++call`, `++load`, `++scry`, `++stay`, and ``++take``, which ultimately call arms in the `event-core` of which we have listed a subset above. Here we will only look at `++call` and `++take`.
89+
90+### ++call
91+When Behn is `%pass`ed a `note` from another vane, that is enacted upon by Arvo via the `++call` gate. The `note` specifies what action to take, which are references to the internal arms. This is done by including in the `note` a symbol such as `%born`, `%rest`, `%wait`, or `%wake`, which ultimately call the arms with those names in the `event-core`.
92+
93+### ++take
94+When Behn is ready to inform another vane or application that a timer has elapsed, Arvo activates the `++take` gate. That is, Arvo `take`s a `gift` from Behn that includes the symbol `%wake`, and `%pass`es it to the the requestee. `%wake` is the only kind of `gift` that Behn can make, but other vanes may possess multiple responses.
reference/arvo-glossary.md+4−4
@@ -104,7 +104,7 @@ Below are Arvo modules, which are called "vanes".
104104 Clay is located at `/home/sys/vane/clay.hoon` within your urbit.
105105
106106 Basic information on using Clay can be found
107− [`here`](@/operations.md). An in-depth explanation
107+ [`here`](@/using/operations/using-your-ship.md). An in-depth explanation
108108 of the architecture can be found
109109 [`here`](@/docs/tutorials/arvo/clay.md).
110110
@@ -403,7 +403,7 @@ information pipeline.
403403
404404Generators are run from the `/gen` directory of your current desk. For example,
405405to run a generator named `whatever.hoon`, you would type `> +whatever` in the
406−[Dojo](@/operations.md#using-the-shell).
406+[Dojo](@/using/operations/using-your-ship.md#using-the-shell).
407407
408408### glyph
409409
@@ -487,7 +487,7 @@ atoms (in this case each with an aura of `%ud`, i.e. unsigned
487487decimal).
488488
489489To parse Hoon source into a hoon AST, use `ream` on a `cord`
490−containing Hoon source. Try the following in [Dojo](@/operations.md#using-the-shell):
490+containing Hoon source. Try the following in [Dojo](@/using/operations/using-your-ship.md#using-the-shell):
491491
492492```
493493(ream ':+(12 7 %a)')
@@ -794,7 +794,7 @@ The head of `+n` is `+2n`, the tail is `+(2n+1)`.
794794_Talk_ is Urbit's built-in chat app. It’s one example of an app that can be
795795built on top of Hall, the Urbit back-end messaging system.
796796
797−_See [Messaging](@/operations.md#messaging). for more information._
797+_See [Messaging](@/using/operations/using-your-ship.md#messaging). for more information._
798798
799799### type
800800
reference/hoon-errors.md+9−11
@@ -36,12 +36,12 @@ But if you make a mistake and write
3636bar
3737```
3838
39−the parser will eat the next hoon below and try to treat it as a
39+the parser will eat the next reference below and try to treat it as a
4040part of the `%+`. This can cause a cascading error somewhere
4141below, usually stopped by a `==` or `--`.
4242
4343When this happens, don't panic! Binary search actually works
44−quite well. Any hoon can be stubbed out as `!!`. Find the
44+quite well. Any reference can be stubbed out as `!!`. Find the
4545prefix of your file that compiles, then work forward until
4646the actual error appears.
4747
@@ -53,12 +53,12 @@ Now your code parses but doesn't compile.
5353
5454Your first step should be to put a `!:` ("zapcol") rune at the
5555top of the file. This is like calling the C compiler with `-g`;
56−it tells the Hoon compiler to generate tracing hoons.
56+it tells the Hoon compiler to generate tracing references.
5757
5858Bear in mind that `!:` breaks tail-call optimization. This is a
5959bug, but a relatively low-priority bug. `!.` turns off `!:`.
60−Note that `!:` and `!.` are hoon-level, not file-level; you can
61−wrap any hoon in either.
60+Note that `!:` and `!.` are reference-level, not file-level; you can
61+wrap any reference in either.
6262
6363### Error trace
6464
@@ -74,7 +74,7 @@ If you have `!:` on, you'll see an error trace, like
7474nest-fail
7575```
7676
77−The bottom of this trace is the line and column of the hoon which
77+The bottom of this trace is the line and column of the reference which
7878failed to compile, then the cause of the error (`nest-fail`).
7979
8080Hoon does not believe in inundating you with possibly irrelevant
@@ -100,8 +100,7 @@ means you tried to pound a square peg into a round hole.
100100What was the peg and what was the hole? Hoon doesn't tell you by
101101default, because moral fiber, and also because in too many cases
102102trivial errors lead to large intimidating dumps. However, you
103−can use the `~!` rune ([**sigzap**](@/docs/reference/hoon-expressions/rune/sig.md#sigzap)) to print the type of
104−any hoon in your stack trace.
103+can use the `~!` rune ([**sigzap**](@/docs/reference/hoon-expressions/rune/sig.md#sigzap)) to print the type of any hoon in your stack trace.
105104
106105For instance, you wrote `(foo bar)` and got a `nest-fail`. Change
107106your code to be:
@@ -122,15 +121,14 @@ In other words, "undeclared variable."
122121
123122The most common subspecies of `find` error is `find.$`, meaning
124123the empty name `$` was not found. This often happens when you
125−use a hoon that does not produce a gate/mold, as a gate/mold. For
124+use a reference that does not produce a gate/mold, as a gate/mold. For
126125instance, `(foo bar)` will give `find.$` if `foo` is not actually a
127126function.
128127
129128### `mint-vain` and `mint-lost`
130129
131130These are errors caused by type inference in pattern matching.
132−`mint-vain` means this hoon is never executed. `mint-lost` means
133−there's a case in a `?-` ([**wuthep**](@/docs/reference/hoon-expressions/rune/wut.md#wuthep)) that isn't handled.
131+`mint-vain` means this hoon is never executed. `mint-lost` means there's a case in a `?-` ([**wuthep**](@/docs/reference/hoon-expressions/rune/wut.md#wuthep)) that isn't handled.
134132
135133## Runtime crashes
136134
reference/hoon-expressions/rune/bar.md+60−60
@@ -2,7 +2,7 @@
22title = "Cores | ('bar')"
33weight = 7
44template = "doc.html"
5−aliases = ["docs/reference/hoon-expressions/rune/bar/"]
5+aliases = ["docs/reference/reference-expressions/rune/bar/"]
66+++
77Core expressions produce cores. A core is a cell of `[battery payload]`.
88The `battery` is code, a battery of Nock formulas. The `payload` is the data
@@ -22,12 +22,12 @@ Produce a **door** (a core with a sample).
2222
2323Regular:
2424
25−```hoon
25+```reference
2626|_ a=spec
27−++ b=term c=hoon
28−++ d=term e=hoon
27+++ b=term c=reference
28+++ d=term e=reference
2929 ...
30−++ f=term g=hoon
30+++ f=term g=reference
3131--
3232```
3333
@@ -49,13 +49,13 @@ The context of the door is the subject of the `|_` expression.
4949
5050##### Expands to
5151
52−```hoon
52+```reference
5353=| a=spec
5454|%
55−++ b=term c=hoon
56−++ d=term e=hoon
55+++ b=term c=reference
56+++ d=term e=reference
5757 ...
58−++ f=term g=hoon
58+++ f=term g=reference
5959--
6060```
6161
@@ -87,7 +87,7 @@ A trivial door:
8787
8888A more interesting door, from the kernel library:
8989
90−```hoon
90+```reference
9191++ ne
9292 |_ tig=@
9393 ++ d (add tig '0')
@@ -112,12 +112,12 @@ Produce a core, `[battery payload]`.
112112
113113Regular:
114114
115−```hoon
115+```reference
116116|%
117−++ a=term b=hoon
118−++ c=term d=hoon
117+++ a=term b=reference
118+++ c=term d=reference
119119 ...
120−++ e=term f=hoon
120+++ e=term f=reference
121121--
122122```
123123
@@ -172,14 +172,14 @@ Produce a gate with a custom sample.
172172
173173Regular:
174174
175−```hoon
176−|: a=hoon b=hoon
175+```reference
176+|: a=reference b=hoon
177177```
178178
179179AST:
180180
181181```
182−[%brcl p=hoon q=hoon]
182+[%brcl p=reference q=hoon]
183183```
184184
185185##### Semantics
@@ -188,7 +188,7 @@ AST:
188188
189189##### Expands to
190190
191−```hoon
191+```reference
192192=> ^~ a
193193 |. b
194194```
@@ -220,14 +220,14 @@ Produce a trap (a core with one arm `$`).
220220
221221Regular:
222222
223−```hoon
224−|. a=hoon
223+```reference
224+|. a=reference
225225```
226226
227227AST:
228228
229229```
230−[%brdt p=hoon]
230+[%brdt p=reference]
231231```
232232
233233Semantics:
@@ -238,8 +238,8 @@ The payload of the core is the subject of the `|.` expression.
238238
239239##### Expands to
240240
241−```hoon
242−|% ++ $ a=hoon
241+```reference
242+|% ++ $ a=reference
243243--
244244```
245245
@@ -288,14 +288,14 @@ Produce a trap (a core with one arm `$`) and evaluate it.
288288
289289Regular:
290290
291−```hoon
292−|- a=hoon
291+```reference
292+|- a=reference
293293```
294294
295295AST:
296296
297297```
298−[%brhp p=hoon]
298+[%brhp p=reference]
299299```
300300
301301##### Semantics
@@ -304,8 +304,8 @@ A `|-` expression produces a core with one arm named `$` and immediately evaluat
304304
305305##### Expands to
306306
307−```hoon
308−=<($ |.(a=hoon))
307+```reference
308+=<($ |.(a=reference))
309309```
310310
311311##### Discussion
@@ -344,12 +344,12 @@ Produce a core whose battery includes a `$` arm and compute the latter.
344344
345345Regular:
346346
347−```hoon
348−|^ a=hoon
349−++ b=term c=hoon
350−++ d=term e=hoon
347+```reference
348+|^ a=reference
349+++ b=term c=reference
350+++ d=term e=reference
351351 ...
352−++ f=term g=hoon
352+++ f=term g=reference
353353--
354354```
355355
@@ -358,7 +358,7 @@ Note: The `++` rune may be replaced with any other rune in the `+` family.
358358AST:
359359
360360```
361−[%brkt p=hoon q=(map term tome)]
361+[%brkt p=reference q=(map term tome)]
362362```
363363
364364##### Semantics
@@ -367,13 +367,13 @@ A `|^` expression produces a multi-arm core whose battery includes a `$` arm, wh
367367
368368##### Expands to
369369
370−```hoon
370+```reference
371371=> |%
372− ++ $ a=hoon
373− ++ b=term c=hoon
374− ++ d=term e=hoon
372+ ++ $ a=reference
373+ ++ b=term c=reference
374+ ++ d=term e=reference
375375 ...
376− ++ f=term g=hoon
376+ ++ f=term g=reference
377377 --
378378$
379379```
@@ -403,14 +403,14 @@ Produce an iron gate.
403403
404404Regular:
405405
406−```hoon
407−|~ a=spec b=hoon
406+```reference
407+|~ a=spec b=reference
408408```
409409
410410AST:
411411
412412```
413−[%brsg p=spec q=hoon]
413+[%brsg p=spec q=reference]
414414```
415415
416416##### Semantics
@@ -419,7 +419,7 @@ A `|~` expression produces an iron gate. `a` defines the sample, and `b` define
419419
420420##### Expands to
421421
422−```hoon
422+```reference
423423^| |=(a b)
424424```
425425
@@ -442,14 +442,14 @@ Produce a wet gate (one-armed core with sample).
442442
443443Regular:
444444
445−```hoon
446−|* a=spec b=hoon
445+```reference
446+|* a=spec b=reference
447447```
448448
449449AST:
450450
451451```
452−[%brtr p=spec q=hoon]
452+[%brtr p=spec q=reference]
453453```
454454
455455##### Semantics
@@ -458,7 +458,7 @@ A `|*` expression produces a wet gate. `a` defines the gate's sample, and `b` i
458458
459459##### Expands to
460460
461−```hoon
461+```reference
462462=| a
463463|@
464464++ $
@@ -508,14 +508,14 @@ Produce a gate (a one-armed core with a sample).
508508
509509Regular:
510510
511−```hoon
512−|= a=spec b=hoon
511+```reference
512+|= a=spec b=reference
513513```
514514
515515AST:
516516
517517```
518−[%brts p=spec q=hoon]
518+[%brts p=spec q=reference]
519519```
520520
521521##### Definition
@@ -526,9 +526,9 @@ The product of a `|=` expression is a dry **gate**, i.e., a Hoon function.
526526
527527##### Expands to
528528
529−```hoon
529+```reference
530530=| a=spec
531−|% ++ $ b=hoon
531+|% ++ $ b=reference
532532--
533533```
534534
@@ -568,12 +568,12 @@ Produce a 'wet' core `[battery payload]`.
568568
569569Regular:
570570
571−```hoon
571+```reference
572572|@
573−++ a=term b=hoon
574−++ c=term d=hoon
573+++ a=term b=reference
574+++ c=term d=reference
575575 ...
576−++ e=term f=hoon
576+++ e=term f=reference
577577--
578578```
579579
@@ -601,14 +601,14 @@ Produce a lead trap.
601601
602602Regular:
603603
604−```hoon
605−|? a=hoon
604+```reference
605+|? a=reference
606606```
607607
608608AST:
609609
610610```
611−[%brwt p=hoon]
611+[%brwt p=reference]
612612```
613613
614614##### Semantics
@@ -617,7 +617,7 @@ A `|?` expression produces a lead trap (i.e., a lead core with one arm named `$`
617617
618618##### Expands to
619619
620−```hoon
620+```reference
621621^? |. a
622622```
623623
reference/hoon-expressions/rune/buc.md+8−8
@@ -2,7 +2,7 @@
22title = "Structures $ ('buc')"
33weight = 12
44template = "doc.html"
5−aliases = ["docs/reference/hoon-expressions/rune/buc/"]
5+aliases = ["docs/reference/reference-expressions/rune/buc/"]
66+++
77The `$` family of runes is used for defining custom types. Strictly speaking,
88these runes are used to produce 'structures'. A structure is a compile-time
@@ -54,11 +54,11 @@ Irregular: `*` makes `%noun`, `^` makes `%cell`, `?` makes
5454
5555### $_ "buccab"
5656
57−`[%bscb p=hoon]`: structure that normalizes to an example.
57+`[%bscb p=reference]`: structure that normalizes to an example.
5858
5959##### Expands to
6060
61−```hoon
61+```reference
6262|=(* p)
6363```
6464
@@ -159,7 +159,7 @@ Irregular (structure mode): `[a b c]` is `$:(a b c)`.
159159
160160##### Expands to
161161
162−```hoon
162+```reference
163163$_ ^|
164164|=(p $:q)
165165```
@@ -217,7 +217,7 @@ Regular: **2-fixed**.
217217
218218### $~ "bucsig"
219219
220−`[%bssg p=hoon q=spec]`: define a custom type default value
220+`[%bssg p=reference q=spec]`: define a custom type default value
221221
222222## Product
223223
@@ -231,8 +231,8 @@ The product of `p`.
231231
232232Regular: **2-fixed**.
233233
234−```hoon
235−$~ p=hoon q=spec
234+```reference
235+$~ p=reference q=spec
236236```
237237
238238`p` defines the default value, and `q` defines everything else about the structure.
@@ -321,7 +321,7 @@ Example:
321321
322322##### Expands to
323323
324−```hoon
324+```reference
325325|= *
326326^=(p %-(q +6))
327327```
reference/hoon-expressions/rune/cen.md+61−61
@@ -2,7 +2,7 @@
22title = "Calls % ('cen')"
33weight = 10
44template = "doc.html"
5−aliases = ["docs/reference/hoon-expressions/rune/cen/"]
5+aliases = ["docs/reference/reference-expressions/rune/cen/"]
66+++
77The `%` family of runes is used for making 'function calls' in Hoon. To be more precise, these runes evaluate the `$` arm in cores, usually after modifying the sample. (The default sample is replaced with the input values given in the call.)
88
@@ -18,25 +18,25 @@ Resolve a wing with changes, preserving type.
1818
1919Regular, tall:
2020
21−```hoon
21+```reference
2222%_ a=wing
23− b=wing c=hoon
24− d=wing e=hoon
23+ b=wing c=reference
24+ d=wing e=reference
2525 ...
26− f=wing g=hoon
26+ f=wing g=reference
2727==
2828```
2929
3030Regular, flat:
3131
32−```hoon
33−%_(a=wing b=wing c=hoon, d=wing e=hoon, ...)
32+```reference
33+%_(a=wing b=wing c=reference, d=wing e=hoon, ...)
3434```
3535
3636AST:
3737
3838```
39−[%cncb p=wing q=(list (pair wing hoon))]
39+[%cncb p=wing q=(list (pair wing reference))]
4040```
4141
4242##### Semantics
@@ -45,7 +45,7 @@ A `%_` expression resolves to the value of the subject at wing `a`, but modified
4545
4646##### Expands to
4747
48−```hoon
48+```reference
4949^+(a %=(a b c, d e, ...))
5050```
5151
@@ -81,19 +81,19 @@ Call a gate with many arguments.
8181
8282Regular:
8383
84−```hoon
85−%: a=hoon
86− b=hoon
87− c=hoon
84+```reference
85+%: a=reference
86+ b=reference
87+ c=reference
8888 ...
89− d=hoon
89+ d=reference
9090==
9191```
9292
9393AST:
9494
9595```
96−[%cncl p=hoon q=(list hoon)]
96+[%cncl p=reference q=(list hoon)]
9797```
9898
9999##### Semantics
@@ -106,7 +106,7 @@ When `%:` is used in tall-form syntax, the series of expressions after `p` must
106106
107107##### Examples
108108
109−```hoon
109+```reference
110110> %: add 22 33 ==
11111155
112112
@@ -135,14 +135,14 @@ Call a gate (function), inverted.
135135
136136Regular:
137137
138−```hoon
139−%. a=hoon b=hoon
138+```reference
139+%. a=reference b=hoon
140140```
141141
142142AST:
143143
144144```
145−[%cndt p=hoon q=hoon]
145+[%cndt p=reference q=hoon]
146146```
147147
148148##### Semantics
@@ -151,8 +151,8 @@ The `%.` rune is for evaluating the `$` arm of a gate, i.e., calling a function.
151151
152152##### Expands to
153153
154−```hoon
155−%-(b=hoon a=hoon)
154+```reference
155+%-(b=reference a=hoon)
156156```
157157
158158##### Discussion
@@ -176,20 +176,20 @@ Call a gate (function).
176176
177177Regular:
178178
179−```hoon
180−%- a=hoon b=hoon
179+```reference
180+%- a=reference b=hoon
181181```
182182
183183Irregular:
184184
185−```hoon
186−(a=hoon b=hoon)
185+```reference
186+(a=reference b=hoon)
187187```
188188
189189AST:
190190
191191```
192−[%cnhp p=hoon q=hoon]
192+[%cnhp p=reference q=hoon]
193193```
194194
195195##### Semantics
@@ -198,7 +198,7 @@ This rune is for evaluating the `$` arm of a gate, i.e., calling a gate as a fun
198198
199199##### Expands to
200200
201−```hoon
201+```reference
202202%~($ a b)
203203```
204204
@@ -225,21 +225,21 @@ Call gate with triple sample.
225225
226226Regular:
227227
228−```hoon
229−%^ a=hoon b=hoon c=hoon d=hoon
228+```reference
229+%^ a=reference b=hoon c=hoon d=hoon
230230```
231231
232232AST:
233233
234234```
235−[%cnkt p=hoon q=hoon r=hoon s=hoon]
235+[%cnkt p=reference q=hoon r=hoon s=hoon]
236236```
237237
238238
239239##### Expands to
240240
241−```hoon
242−%-(a=hoon [b=hoon c=hoon d=hoon])
241+```reference
242+%-(a=reference [b=hoon c=hoon d=hoon])
243243```
244244
245245##### Examples
@@ -259,14 +259,14 @@ Call gate with a cell sample.
259259
260260Regular:
261261
262−```hoon
263−%+ a=hoon b=hoon c=hoon
262+```reference
263+%+ a=reference b=hoon c=hoon
264264```
265265
266266AST:
267267
268268```
269−[%cnls p=hoon q=hoon r=hoon]
269+[%cnls p=reference q=hoon r=hoon]
270270```
271271
272272##### Semantics
@@ -275,8 +275,8 @@ A `%+` expression is for calling a gate with a cell sample. `a` is the gate to
275275
276276##### Expands to
277277
278−```hoon
279−%-(a=hoon [b=hoon c=hoon])
278+```reference
279+%-(a=reference [b=hoon c=hoon])
280280```
281281
282282##### Examples
@@ -296,12 +296,12 @@ Evaluate an arm in a door.
296296
297297Regular:
298298
299−```hoon
300−%~ a=wing b=hoon
301− c=hoon
302− d=hoon
299+```reference
300+%~ a=wing b=reference
301+ c=reference
302+ d=reference
303303 ...
304− e=hoon
304+ e=reference
305305==
306306```
307307
@@ -313,7 +313,7 @@ Irregular:
313313AST:
314314
315315```
316−[%cnsg p=wing q=hoon r=(list hoon)]
316+[%cnsg p=wing q=reference r=(list hoon)]
317317```
318318
319319##### Semantics
@@ -328,7 +328,7 @@ See also [`|_`](@/docs/reference/hoon-expressions/rune/bar.md#barcab).
328328
329329##### Examples
330330
331−```hoon
331+```reference
332332> =mycore |_ a=@
333333 ++ plus-two (add 2 a)
334334 ++ double (mul 2 a)
@@ -348,19 +348,19 @@ Evaluate an expression, then resolve a wing with changes.
348348
349349Regular:
350350
351−```hoon
352−%* a=wing b=hoon
353− c=wing d=hoon
354− e=wing f=hoon
351+```reference
352+%* a=wing b=reference
353+ c=wing d=reference
354+ e=wing f=reference
355355 ...
356− g=wing h=hoon
356+ g=wing h=reference
357357==
358358```
359359
360360AST:
361361
362362```
363−[%cntr p=wing q=hoon r=(list (pair wing hoon))]
363+[%cntr p=wing q=reference r=(list (pair wing hoon))]
364364```
365365
366366##### Semantics
@@ -369,13 +369,13 @@ A `%*` expression evaluates some arbitrary Hoon expression, `b`, and then resolv
369369
370370##### Expands to
371371
372−```hoon
373−=+ b=hoon
372+```reference
373+=+ b=reference
374374%= a=wing
375− c=wing d=hoon
376− e=wing f=hoon
375+ c=wing d=reference
376+ e=wing f=reference
377377 ...
378− g=wing h=hoon
378+ g=wing h=reference
379379==
380380```
381381
@@ -411,12 +411,12 @@ Resolve a wing with changes.
411411
412412Regular:
413413
414−```hoon
414+```reference
415415%= a=wing
416− b=wing c=hoon
417− d=wing e=hoon
416+ b=wing c=reference
417+ d=wing e=reference
418418 ...
419− f=wing g=hoon
419+ f=wing g=reference
420420==
421421```
422422
@@ -427,7 +427,7 @@ Irregular:
427427AST:
428428
429429```
430−[%cnts p=wing q=(list (pair wing hoon))]
430+[%cnts p=wing q=(list (pair wing reference))]
431431```
432432
433433##### Semantics
@@ -452,7 +452,7 @@ a wing, we would just be mutating `+6` within the core that defines the
452452
453453Here's that again in tall form:
454454
455−```hoon
455+```reference
456456=+ foo
457457=> %= +2
458458 +6 baz
reference/hoon-expressions/rune/ket.md+16−16
@@ -2,7 +2,7 @@
22title = "Casts ^ ('ket')"
33weight = 11
44template = "doc.html"
5−aliases = ["docs/reference/hoon-expressions/rune/ket/"]
5+aliases = ["docs/reference/reference-expressions/rune/ket/"]
66+++
77[`^-` ("kethep")](#kethep), [`^+` ("ketlus")](#ketlus), and
88[`^=` ("kettis")](#kettis) let us adjust types without violating type
@@ -15,7 +15,7 @@ it never allows invalid nests, it sometimes rejects valid nests.
1515
1616### ^| "ketbar"
1717
18−`[%ktbr p=hoon]`: convert a gold core to an iron core (contravariant).
18+`[%ktbr p=reference]`: convert a gold core to an iron core (contravariant).
1919
2020##### Produces
2121
@@ -87,11 +87,11 @@ ford: %ride failed to execute:
8787
8888### ^. "ketdot"
8989
90−`[%ktdt p=hoon q=hoon]`: typecast on value produced by passing `q` to `p`.
90+`[%ktdt p=reference q=hoon]`: typecast on value produced by passing `q` to `p`.
9191
9292##### Expands to
9393
94−```hoon
94+```reference
9595^+(%:(p q) q)
9696```
9797
@@ -99,8 +99,8 @@ ford: %ride failed to execute:
9999
100100Regular: **2-fixed**.
101101
102−```hoon
103−^. p=hoon q=hoon
102+```reference
103+^. p=reference q=hoon
104104```
105105
106106##### Discussion
@@ -128,11 +128,11 @@ mint-vain
128128
129129### ^- "kethep"
130130
131−`[%kthp p=spec q=hoon]`: typecast by explicit type label.
131+`[%kthp p=spec q=reference]`: typecast by explicit type label.
132132
133133##### Expands to
134134
135−```hoon
135+```reference
136136^+(^*(p) q)
137137```
138138
@@ -172,7 +172,7 @@ infinite loop in the compiler).
172172
173173### ^+ "ketlus"
174174
175−`[%ktls p=hoon q=hoon]`: typecast by inferred type.
175+`[%ktls p=reference q=hoon]`: typecast by inferred type.
176176
177177##### Produces
178178
@@ -191,7 +191,7 @@ Regular: **2-fixed**.
191191
192192### ^& "ketpam"
193193
194−`[%ktpm p=hoon]`: convert a core to a zinc core (covariant).
194+`[%ktpm p=reference]`: convert a core to a zinc core (covariant).
195195
196196##### Produces
197197
@@ -244,7 +244,7 @@ ford: %ride failed to compute type:
244244
245245### ^~ "ketsig"
246246
247−`[%ktsg p=hoon]`: fold constant at compile time.
247+`[%ktsg p=reference]`: fold constant at compile time.
248248
249249##### Produces
250250
@@ -276,7 +276,7 @@ A default value (i.e., 'bunt value') of the type `p`.
276276
277277Regular: **1-fixed**.
278278
279−```hoon
279+```reference
280280^* p=spec
281281```
282282
@@ -288,7 +288,7 @@ Irregular: `*p`.
288288
289289Regular:
290290
291−```hoon
291+```reference
292292> ^* @
2932930
294294
@@ -304,7 +304,7 @@ Regular:
304304
305305Irregular:
306306
307−```hoon
307+```reference
308308> *@
3093090
310310
@@ -317,7 +317,7 @@ Irregular:
317317
318318### ^= "kettis"
319319
320−`[%ktts p=skin q=hoon]`: Bind name to a value.
320+`[%ktts p=skin q=reference]`: Bind name to a value.
321321
322322##### Produces
323323
@@ -353,7 +353,7 @@ a=1
353353
354354### ^? "ketwut"
355355
356−`[%ktwt p=hoon]`: convert any core to a lead core (bivariant).
356+`[%ktwt p=reference]`: convert any core to a lead core (bivariant).
357357
358358##### Produces
359359
reference/hoon-expressions/rune/tis.md+27−27
@@ -2,7 +2,7 @@
22title = "Change Subject = ('tis')"
33weight = 5
44template = "doc.html"
5−aliases = ["/docs/reference/hoon-expressions/rune/tis/"]
5+aliases = ["/docs/reference/reference-expressions/rune/tis/"]
66+++
77These runes modify the subject. (Or more precisely, they
88evaluate at least one of their subexpressions with a modified subject.)
@@ -26,7 +26,7 @@ different situations. Hence the whole family of `=` runes.
2626
2727### => "tisgar"
2828
29−`[%tsgr p=hoon q=hoon]`: compose two expressions.
29+`[%tsgr p=reference q=hoon]`: compose two expressions.
3030
3131##### Produces
3232
@@ -49,11 +49,11 @@ Regular: **2-fixed**.
4949### =| "tisbar"
5050
5151
52−`[%tsbr p=spec q=hoon]`: combine a default type value with the subject.
52+`[%tsbr p=spec q=reference]`: combine a default type value with the subject.
5353
5454##### Expands to
5555
56−```hoon
56+```reference
5757=+(*p q)
5858```
5959
@@ -80,11 +80,11 @@ Speaking more loosely, `=|` usually "declares a variable" which is "uninitialize
8080
8181### =: "tiscol"
8282
83−`[%tscl p=(list (pair wing hoon)) q=hoon]`: change multiple legs in the subject.
83+`[%tscl p=(list (pair wing reference)) q=hoon]`: change multiple legs in the subject.
8484
8585##### Expands to
8686
87−```hoon
87+```reference
8888=>(%_(. p) q)
8989```
9090
@@ -109,7 +109,7 @@ This rune is like `=.`, but for modifying the values of multiple legs of the sub
109109
110110### =, "tiscom"
111111
112−`[%tscm p=hoon q=hoon]`: expose namespace
112+`[%tscm p=reference q=hoon]`: expose namespace
113113
114114`p` evaluates to a noun with some namespace. From within `q` you may access `p`'s names without a wing path (i.e., you can use face `b` rather than `b.p`). This is especially useful for calling arms from an imported library core or for calling arms from a stdlib core repeatedly.
115115
@@ -144,11 +144,11 @@ With a dojo-defined face:
144144
145145### =. "tisdot"
146146
147−`[%tsdt p=wing q=hoon r=hoon]`: change one leg in the subject.
147+`[%tsdt p=wing q=reference r=hoon]`: change one leg in the subject.
148148
149149##### Expands to
150150
151−```hoon
151+```reference
152152=>(%_(. p q) r)
153153```
154154
@@ -180,11 +180,11 @@ nest-fail
180180
181181### =- "tishep"
182182
183−`[%tshp p=hoon q=hoon]`: combine a new noun with the subject, inverted.
183+`[%tshp p=reference q=hoon]`: combine a new noun with the subject, inverted.
184184
185185##### Expands to
186186
187−```hoon
187+```reference
188188=>([q .] p)
189189```
190190
@@ -209,12 +209,12 @@ Regular: **2-fixed**.
209209
210210### =^ "tisket"
211211
212−`[%tskt p=skin q=wing r=hoon s=hoon]`: pin the head of a pair; change
212+`[%tskt p=skin q=wing r=reference s=hoon]`: pin the head of a pair; change
213213a leg with the tail.
214214
215215##### Expands to
216216
217−```hoon
217+```reference
218218=/(p -.r =.(q +.r s))
219219```
220220
@@ -249,11 +249,11 @@ random number, so we use `=^`:
249249
250250### =< "tisgal"
251251
252−`[%tsgl p=hoon q=hoon]`: compose two expressions, inverted.
252+`[%tsgl p=reference q=hoon]`: compose two expressions, inverted.
253253
254254##### Expands to
255255
256−```hoon
256+```reference
257257=>(q p)
258258```
259259
@@ -287,11 +287,11 @@ Irregular: `foo:baz` is `=<(foo baz)`.
287287### =+ "tislus"
288288
289289
290−`[%tsls p=hoon q=hoon]`: combine a new noun with the subject.
290+`[%tsls p=reference q=hoon]`: combine a new noun with the subject.
291291
292292##### Expands to
293293
294−```hoon
294+```reference
295295=>([p .] q)
296296```
297297
@@ -309,11 +309,11 @@ Loosely speaking, `=+` is the simplest way of "declaring a variable."
309309
310310### =; "tismic"
311311
312−`[%tsmc p=skin q=hoon r=hoon]`: combine a named noun with the subject, possibly with type annotation; inverted order.
312+`[%tsmc p=skin q=reference r=hoon]`: combine a named noun with the subject, possibly with type annotation; inverted order.
313313
314314##### Expands to
315315
316−```hoon
316+```reference
317317=/(p r q)
318318```
319319
@@ -338,25 +338,25 @@ Regular: **3-fixed**.
338338
339339### =/ "tisfas"
340340
341−`[%tsfs p=skin q=hoon r=hoon]`: combine a named noun with the subject, possibly with type annotation.
341+`[%tsfs p=skin q=reference r=hoon]`: combine a named noun with the subject, possibly with type annotation.
342342
343343##### Expands to
344344
345345**if `p` is a name**, (e.g. `a`):
346346
347−```hoon
347+```reference
348348=+(^=(p q) r)
349349```
350350
351351**if `p` is a name with a type** (e.g., `a=@`):
352352
353−```hoon
353+```reference
354354=+(^-(p q) r)
355355```
356356
357357### Desugaring
358358
359−```hoon
359+```reference
360360?@ p
361361 =+ p=q
362362 r
@@ -388,7 +388,7 @@ Regular: **3-fixed**.
388388### =~ "tissig"
389389
390390
391−`[%tssg p=(list hoon)]`: compose many expressions.
391+`[%tssg p=(list reference)]`: compose many expressions.
392392
393393##### Produces
394394
@@ -423,7 +423,7 @@ Regular: **running**.
423423
424424### =* "tistar"
425425
426−`[%tstr p=term q=hoon r=hoon]`: define an alias.
426+`[%tstr p=term q=reference r=hoon]`: define an alias.
427427
428428##### Produces
429429
@@ -456,11 +456,11 @@ The difference between aliasing and pinning is that pinning changes the subject,
456456
457457### =? "tiswut"
458458
459−`[$tswt p=wing q=hoon r=hoon s=hoon]`: conditionally change one leg in the subject.
459+`[$tswt p=wing q=reference r=hoon s=hoon]`: conditionally change one leg in the subject.
460460
461461##### Expands to
462462
463−```hoon
463+```reference
464464=. p ?:(q r p)
465465s
466466```
reference/hoon-expressions/rune/wut.md+27−27
@@ -2,7 +2,7 @@
22title = "Conditionals ? ('wut')"
33weight = 6
44template = "doc.html"
5−aliases = ["docs/reference/hoon-expressions/rune/wut/"]
5+aliases = ["docs/reference/reference-expressions/rune/wut/"]
66+++
77Hoon has the usual program control branches. It also has the usual logical
88operators: AND `?&`, OR `?|`, and NOT `?!`. It also has a `?=` rune that tests
@@ -32,11 +32,11 @@ side is taken), it fails with an error.
3232
3333### ?> "wutgar"
3434
35−`[%wtgr p=hoon q=hoon]`: positive assertion.
35+`[%wtgr p=reference q=hoon]`: positive assertion.
3636
3737##### Expands to
3838
39−```hoon
39+```reference
4040?.(p !! q)
4141```
4242
@@ -70,19 +70,19 @@ nest-fail
7070
7171### ?| "wutbar"
7272
73−`[%wtbr p=(list hoon)]`: logical OR.
73+`[%wtbr p=(list reference)]`: logical OR.
7474
7575##### Expands to
7676
7777**Pseudocode**: `a`, `b`, `c`, ... as elements of `p`:
7878
79−```hoon
79+```reference
8080?:(a & ?:(b & ?:(c & ?:(... ?:(z & |)))))
8181```
8282
8383##### Desugaring
8484
85−```hoon
85+```reference
8686|-
8787?~ p
8888 |
@@ -109,7 +109,7 @@ Irregular: `|(foo bar baz)` is `?|(foo bar baz)`.
109109
110110### ?: "wutcol" {#wutcol}
111111
112−`[%wtcl p=hoon q=hoon r=hoon]`: branch on a boolean test.
112+`[%wtcl p=reference q=hoon r=hoon]`: branch on a boolean test.
113113
114114##### Produces
115115
@@ -157,11 +157,11 @@ Note also that all other branching expressions reduce to `?:`.
157157
158158### ?. "wutdot"
159159
160−`[%wtdt p=hoon q=hoon r=hoon]`: branch on a boolean test, inverted.
160+`[%wtdt p=reference q=hoon r=hoon]`: branch on a boolean test, inverted.
161161
162162##### Expands to
163163
164−```hoon
164+```reference
165165?:(p r q)
166166```
167167
@@ -200,7 +200,7 @@ As is usual with inverted forms, use `?.` when the yes-case expression is much t
200200
201201**Pseudocode**: `a`, `b`, `c`, ... as elements of `q`:
202202
203−```hoon
203+```reference
204204?: ?=(p.a p) q.a
205205?: ?=(p.b p) q.b
206206?: ?=(p.c p) q.c
@@ -210,7 +210,7 @@ As is usual with inverted forms, use `?.` when the yes-case expression is much t
210210
211211##### Desugaring
212212
213−```hoon
213+```reference
214214|-
215215?. q
216216 ~|(%mint-lost !!)
@@ -256,12 +256,12 @@ will throw `mint-vain`.
256256
257257### ?^ "wutket"
258258
259−`[%wtkt p=wing q=hoon r=hoon]`: branch on whether a wing
259+`[%wtkt p=wing q=reference r=hoon]`: branch on whether a wing
260260of the subject is a cell.
261261
262262##### Expands to
263263
264−```hoon
264+```reference
265265?:(?=(^ p) q r)
266266```
267267
@@ -289,11 +289,11 @@ The type of the wing, `p`, must not be known to be either an atom or a cell, or
289289
290290### ?< "wutgal"
291291
292−`[%wtgl p=hoon q=hoon]`: negative assertion.
292+`[%wtgl p=reference q=hoon]`: negative assertion.
293293
294294##### Expands to
295295
296−```hoon
296+```reference
297297?:(p !! q)
298298```
299299
@@ -327,14 +327,14 @@ nest-fail
327327
328328### ?+ "wutlus"
329329
330−`[%wtls p=wing q=hoon r=(list (pair spec hoon))]`: switch against
330+`[%wtls p=wing q=reference r=(list (pair spec hoon))]`: switch against
331331a union, with a default.
332332
333333##### Expands to
334334
335335**Pseudocode**: `a`, `b`, `c`, ... as elements of `r`:
336336
337−```hoon
337+```reference
338338?: ?=(p.a p) q.a
339339?: ?=(p.b p) q.b
340340?: ?=(p.c p) q.c
@@ -344,7 +344,7 @@ q
344344
345345##### Desugaring
346346
347−```hoon
347+```reference
348348|-
349349?. r
350350 q
@@ -384,19 +384,19 @@ If there is a case that is never taken you'll get a `mint-vain` error.
384384
385385### ?& "wutpam"
386386
387−`[%wtpm p=(list hoon)]`: logical AND.
387+`[%wtpm p=(list reference)]`: logical AND.
388388
389389##### Expands to
390390
391391**Pseudocode**: `a`, `b`, `c`, ... as elements of `p`:
392392
393−```hoon
393+```reference
394394?.(a | ?.(b | ?.(c | ?.(... ?.(z | &)))))
395395```
396396
397397##### Desugaring
398398
399−```hoon
399+```reference
400400|-
401401?~ p
402402 &
@@ -423,11 +423,11 @@ Irregular: `&(foo bar baz)` is `?&(foo bar baz)`.
423423
424424### ?~ "wutsig"
425425
426−`[%wtsg p=wing q=hoon r=hoon]`: branch on whether a wing of the subject is null.
426+`[%wtsg p=wing q=reference r=hoon]`: branch on whether a wing of the subject is null.
427427
428428##### Expands to
429429
430−```hoon
430+```reference
431431?:(?=($~ p) q r)
432432```
433433
@@ -486,11 +486,11 @@ A common error is `find.$`, meaning `p` is not a type.
486486
487487### ?@ "wutvat"
488488
489−`[%wtpt p=wing q=hoon r=hoon]`: branch on whether a wing of the subject is an atom.
489+`[%wtpt p=wing q=reference r=hoon]`: branch on whether a wing of the subject is an atom.
490490
491491##### Expands to
492492
493−```hoon
493+```reference
494494?:(?=(@ p) q r)
495495```
496496
@@ -518,11 +518,11 @@ The type of the wing, `p`, must not be known to be either an atom or a cell, or
518518
519519### ?! "wutzap"
520520
521−`[%wtzp p=hoon]`: logical NOT.
521+`[%wtzp p=reference]`: logical NOT.
522522
523523##### Expands to
524524
525−```hoon
525+```reference
526526.=(| p)
527527```
528528
reference/library/1a.mddeleted−680
@@ -1,680 +0,0 @@
1−+++
2−title = "1a: Basic Arithmetic"
3−weight = 1
4−template = "doc.html"
5−aliases = ["/docs/reference/library/1a"]
6−+++
7−### `++add`
8−
9−Add
10−
11−Produces the sum of `a` and `b`.
12−
13−#### Accepts
14−
15−`a` is an atom.
16−
17−`b` is an atom.
18−
19−#### Produces
20−
21−An atom.
22−
23−#### Source
24−
25−```hoon
26− ++ add
27− ~/ %add
28− |= [a=@ b=@]
29− ^- @
30− ?: =(0 a) b
31− $(a (dec a), b +(b))
32−```
33−
34−#### Examples
35−
36−```
37− > (add 2 2)
38− 4
39−
40− > (add 1 1.000.000)
41− 1.000.001
42−
43− > (add 1.333 (mul 2 2))
44− 1.337
45−
46− > (add 'a' 4)
47− 101
48−
49− > (add 'a' 'b')
50− 195
51−
52− > (add 0xc 0xf)
53− 27
54−
55− > `@ux`(add 0xc 0xf)
56− 0x1b
57−```
58−
59−---
60−### `++dec`
61−
62−Decrement
63−
64−Decrements `a` by `1`.
65−
66−#### Accepts
67−
68−`a` is an atom.
69−
70−#### Produces
71−
72−An atom.
73−
74−#### Source
75−
76−```hoon
77− ++ dec
78− ~/ %dec
79− |= a=@
80− ~| %decrement-underflow
81− ?< =(0 a)
82− =+ b=0
83− |- ^- @
84− ?: =(a +(b)) b
85− $(b +(b))
86−```
87−
88−#### Examples
89−
90−```
91− > (dec 7)
92− 6
93−
94− > (dec 0)
95− ! decrement-underflow
96− ! exit
97−
98− > (dec 'b')
99− 97
100− > `@t`(dec 'b')
101− 'a'
102−
103− > (dec 0xc)
104− 11
105− > `@ux`(dec 0xc)
106− 0xb
107−```
108−
109−
110−---
111−### `++div`
112−
113−Divide
114−
115−Computes `a` divided by `b` without remainder.
116−
117−#### Accepts
118−
119−`a` is an atom.
120−
121−`b` is an atom.
122−
123−#### Produces
124−
125−An atom.
126−
127−#### Source
128−
129−```hoon
130− ++ div
131− ~/ %div
132− |: [a=`@`1 b=`@`1]
133− ^- @
134− ~_ leaf+"divide-by-zero"
135− ?< =(0 b)
136− =+ c=0
137− |-
138− ?: (lth a b) c
139− $(a (sub a b), c +(c))
140−```
141−
142−#### Examples
143−
144−```
145− > (div 4 2)
146− 2
147−
148− > (div 17 8)
149− 2
150−
151− > (div 20 30)
152− 0
153−
154− > (div 'ab' 'a')
155− 259
156− > `@`'ab'
157− 25.185
158− > `@`a
159− 97
160−
161− > (div 0x9f 0x29)
162− 6
163−```
164−
165−---
166−### `++dvr`
167−
168−Divide with remainder
169−
170−Computes `a` divided by `b`, producing the quotient and the remainder.
171−
172−#### Accepts
173−
174−`a` is an atom.
175−
176−`b` is an atom.
177−
178−#### Produces
179−
180−A cell of atoms.
181−
182−#### Source
183−
184−```hoon
185− ++ dvr
186− ~/ %dvr
187− |= [a=@ b=@]
188− ^- [p=@ q=@]
189− [(div a b) (mod a b)]
190−```
191−
192−#### Examples
193−
194−```
195− > (dvr 17 8)
196− [p=2 q=1]
197−
198− > (dvr 17 6)
199− [p=2 q=5]
200−
201− > (dvr 18 6)
202− [p=3 q=0]
203−
204− > (dvr 4 2)
205− [p=2 q=0]
206−
207− > (dvr 'ab 'a')
208− [p=259 q=62]
209− > `@`'a'
210− 97
211− > `@`'ab'
212− 25.185
213−```
214−
215−---
216−### `++gte`
217−
218−Greater-than/equal
219−
220−Tests whether `a` is greater than or equal to `b`.
221−
222−#### Accepts
223−
224−`a` is an atom.
225−
226−`b` is an atom.
227−
228−#### Produces
229−
230−A flag.
231−
232−#### Source
233−
234−```hoon
235− ++ gte
236− ~/ %gte
237− |= [a=@ b=@]
238− ^- ?
239− !(lth a b)
240−```
241−
242−#### Examples
243−
244−```
245− > (gte 100 10)
246− %.y
247−
248− > (gte 4 4)
249− %.y
250−
251− > (gte 3 4)
252− %.n
253−```
254−
255−---
256−### `++gth`
257−
258−Greater-than
259−
260−Tests whether `a` is greater than `b`.
261−
262−#### Accepts
263−
264−`a` is an atom.
265−
266−`b` is an atom.
267−
268−#### Produces
269−
270−A flag.
271−
272−#### Source
273−
274−```hoon
275− ++ gth
276− ~/ %gth
277− |= [a=@ b=@]
278− ^- ?
279− !(lte a b)
280−```
281−
282−
283−#### Examples
284−
285−```
286− > (gth 'd' 'c')
287− %.y
288−
289− > (gth ~h1 ~m61)
290− %.n
291−
292− > (gth 'steak' 'brisket')
293− %.n
294−```
295−
296−---
297−### `++lte`
298−
299−Less-than/equal
300−
301−Tests whether `a` is less than or equal to `b`.
302−
303−#### Accepts
304−
305−`a` is an atom.
306−
307−`b` is an atom.
308−
309−#### Produces
310−
311−A flag.
312−
313−#### Source
314−
315−```hoon
316− ++ lte
317− ~/ %lte
318− |= [a=@ b=@]
319− |(=(a b) (lth a b))
320−```
321−
322−#### Examples
323−
324−```
325− > (lte 4 5)
326− %.y
327−
328− > (lte 5 4)
329− %.n
330−
331− > (lte 5 5)
332− %.y
333−
334− > (lte 0 0)
335− %.y
336−
337−
338− > (lte 'a' 'b')
339− %.y
340− > `@`'a'
341− 97
342− > `@`'b'
343− 98
344−
345− > (lte 'abraham' 'bob')
346− %.n
347−
348− > (lte ~m61 ~h1)
349− %.n
350−```
351−
352−
353−---
354−### `++lth`
355−
356−Less-than
357−
358−Tests whether `a` is less than `b`.
359−
360−#### Accepts
361−
362−`a` is an atom.
363−
364−`b` is an atom.
365−
366−#### Produces
367−
368−A flag.
369−
370−#### Source
371−
372−```hoon
373− ++ lth
374− ~/ %lth
375− |= [a=@ b=@]
376− ^- ?
377− ?& !=(a b)
378− |-
379− ?| =(0 a)
380− ?& !=(0 b)
381− $(a (dec a), b (dec b))
382− == == ==
383−```
384−
385−#### Examples
386−
387−```
388− > (lth 4 5)
389− %.y
390−
391− > (lth 5 4)
392− %.n
393−
394− > (lth 5 5)
395− %.n
396−
397− > (lth 5 0)
398− %.n
399−
400− > (lth 'a' 'b')
401− %.y
402− > `@`'a'
403− 97
404− > `@`'b'
405− 98
406−
407− > (lth 'abraham' 'bob')
408− %.n
409−```
410−
411−---
412−### `++max`
413−
414−Maximum
415−
416−Computes the greater of `a` and `b`.
417−
418−#### Accepts
419−
420−`a` is an atom.
421−
422−`b` is an atom.
423−
424−#### Produces
425−
426−An atom.
427−
428−#### Source
429−
430−```hoon
431− ++ max
432− ~/ %max
433− |= [a=@ b=@]
434− ^- @
435− ?: (gth a b) a
436− b
437−```
438−
439−#### Examples
440−
441−```
442− > (max 10 100)
443− 100
444−
445− > (max 10.443 9)
446− 10.443
447−
448− > (max 1 1)
449− 1
450−
451− > (max 'abraham' 'bob')
452− 30.787.873.400.840.801
453−
454− > `@t`(max 'abraham' 'bob')
455− 'abraham'
456−
457− > `@t`(max 'abraham' 'benjamin')
458− 'benjamin'
459−
460− > `@dr`(max ~m6 ~h1)
461− ~h1
462−
463− >`@ux`(max 0xe1 0x1e)
464− 0xe1
465−```
466−
467−---
468−### `++min`
469−
470−Minimum
471−
472−Computes the lesser of `a` and `b`.
473−
474−#### Accepts
475−
476−`a` is an atom.
477−
478−`b` is an atom.
479−
480−#### Produces
481−
482−An atom.
483−
484−#### Source
485−
486−```hoon
487− ++ min
488− ~/ %min
489− |= [a=@ b=@]
490− ^- @
491− ?: (lth a b) a
492− b
493−```
494−
495−#### Examples
496−
497−```
498− > (min 10 100)
499− 10
500−
501− > (min 10.443 9)
502− 9
503−
504− > (min 1 1)
505− 1
506−
507− > (min 'abraham' 'bob')
508− 6.451.042
509−
510− > `@t`(min 'abraham' 'bob')
511− 'bob'
512−
513− > `@t`(min 'abraham' 'benjamin')
514− 'abraham'
515−
516− > `@dr`(min ~m6 ~h1)
517− ~m6
518−```
519−
520−
521−---
522−### `++mod`
523−
524−Modulus
525−
526−Computes the remainder of dividing `a` by `b`.
527−
528−#### Accepts
529−
530−`a` is an atom.
531−
532−`b` is an atom.
533−
534−#### Produces
535−
536−An atom.
537−
538−#### Source
539−
540−```hoon
541− ++ mod
542− ~/ %mod
543− |: [a=`@`1 b=`@`1]
544− ^- @
545− ?< =(0 b)
546− (sub a (mul b (div a b)))
547−```
548−
549−#### Examples
550−
551−```
552− > (mod 5 2)
553− 1
554−
555− > (mod 5 5)
556− 0
557−
558− > (mod 2 5)
559− 2
560−
561− > (mod 40 20)
562− 0
563−
564− > `@`'c'
565− 99
566− >`@`'a'
567− 97
568− > (mod 'c' 'a')
569− 2
570−```
571−
572−---
573−### `++mul`
574−
575−Multiply
576−
577−Multiplies `a` by `b`.
578−
579−#### Accepts
580−
581−`a` is an atom.
582−
583−`b` is an atom.
584−
585−#### Produces
586−
587−An atom.
588−
589−#### Source
590−
591−```hoon
592− ++ mul
593− ~/ %mul
594− |: [a=`@`1 b=`@`1]
595− ^- @
596− =+ c=0
597− |-
598− ?: =(0 a) c
599− $(a (dec a), c (add b c))
600−```
601−
602−#### Examples
603−
604−```
605− > (mul 3 4)
606− 12
607−
608− > (mul 0 1)
609− 0
610−
611− > `@`'a'
612− 97
613− > `@`'b'
614− 98
615− > (mul 'a' 'b')
616− 9.506
617−
618− >`@ux`(mul 0x1f 0xe)
619− 0x1b2
620−```
621−
622−
623−---
624−### `++sub`
625−
626−Subtract
627−
628−Subtracts `b` from `a`.
629−
630−#### Accepts
631−
632−`a` is an atom.
633−
634−`b` is an atom.
635−
636−#### Produces
637−
638−An atom.
639−
640−#### Source
641−
642−```hoon
643− ++ sub
644− ~/ %sub
645− |= [a=@ b=@]
646− ~_ leaf+"subtract-underflow"
647− ^- @
648− ?: =(0 b) a
649− $(a (dec a), b (dec b))
650−```
651−
652−
653−#### Examples
654−
655−```
656− > (sub 10 5)
657− 5
658−
659− > (sub 243 44)
660− 199
661−
662− > (sub 5 0)
663− 5
664−
665− > (sub 0 5)
666− ! subtract-underflow
667− ! exit
668−
669− > (sub 'c' 'a')
670− 2
671− > `@`'c'
672− 99
673− > `@`'a'
674− 97
675−
676− > (sub 0x1f 0xe)
677− 17
678− > `@ux`(sub 0x1f 0xe)
679− 0x11
680−```
reference/library/1b.md+1−1
@@ -4,7 +4,7 @@ weight = 2
44template = "doc.html"
55aliases = ["/docs/reference/library/1b"]
66+++
7−Check out the Nock [explanation](@/docs/nock/_index.md) for more
7+Check out the Nock [explanation](@/docs/tutorials/nock/_index.md) for more
88information on the tree-addressing system.
99
1010### `++cap`
reference/library/1c.md+12−12
@@ -12,7 +12,7 @@ Atom representing block size. A block of size `a` has a bitwidth of `2^a`.
1212
1313#### Source
1414
15−```hoon
15+```reference
1616 ++ bloq @
1717```
1818
@@ -104,7 +104,7 @@ product noun. If used dryly as a type, the subject must have a sample type of
104104
105105#### Source
106106
107−```hoon
107+```reference
108108 ++ gate
109109 $-(* *)
110110```
@@ -143,7 +143,7 @@ homogenous type.
143143
144144#### Source
145145
146−```hoon
146+```reference
147147 ++ list
148148 |*(a=mold $@($~ (lest a)))
149149```
@@ -177,7 +177,7 @@ A mold generator. Puts face of `p` on the passed-in mold.
177177
178178#### Source
179179
180−```hoon
180+```reference
181181 ++ lone
182182 |*(a=mold [p=a])
183183```
@@ -210,7 +210,7 @@ A mold generator. Produces a tuple of two of the types passed in.
210210
211211#### Source
212212
213−```hoon
213+```reference
214214 ++ pair
215215 |*([a=mold b=mold] [p=a q=b])
216216```
@@ -235,7 +235,7 @@ A mold generator. A `list` without the faces `i` and `t`.
235235
236236#### Source
237237
238−```hoon
238+```reference
239239 ++ pole
240240 |*(a=mold $@($~ [a (pole a)]))
241241```
@@ -261,7 +261,7 @@ A mold generator. Produces a tuple of four of the types passed in.
261261
262262#### Source
263263
264−```hoon
264+```reference
265265 ++ qual
266266 |* [a=mold b=mold c=mold d=mold]
267267 [p=a q=b r=c s=d]
@@ -286,7 +286,7 @@ A mold generator. Produces a tuple of a `list` of `a` and the mold of `b`.
286286
287287#### Source
288288
289−```hoon
289+```reference
290290 ++ quip
291291 |*([a=mold b=mold] [(list a) b])
292292```
@@ -315,7 +315,7 @@ A trap is a core with one arm `$`.
315315
316316#### Source
317317
318−```hoon
318+```reference
319319 ++ trap
320320 |*(a=mold _|?(*a))
321321```
@@ -344,7 +344,7 @@ left/right sub `tree` of the same type. Pretty-printed with `{}`.
344344
345345#### Source
346346
347−```hoon
347+```reference
348348 ++ tree
349349 |*(a=mold $@($~ [n=a l=(tree a) r=(tree a)]))
350350```
@@ -366,7 +366,7 @@ A mold generator. A mold of the tuple of the three types passed in.
366366
367367#### Source
368368
369−```hoon
369+```reference
370370 ++ trel
371371 |*([a=mold b=mold c=mold] [p=a q=b r=c])
372372```
@@ -392,7 +392,7 @@ type that was passed in.
392392
393393#### Source
394394
395−```hoon
395+```reference
396396 ++ unit
397397 |*(a=mold $@($~ [$~ u=a]))
398398```
reference/library/2a.mddeleted−449
@@ -1,449 +0,0 @@
1−+++
2−title = "2a: Unit Logic"
3−weight = 4
4−template = "doc.html"
5−aliases = ["/docs/reference/library/2a"]
6−+++
7−### `++biff`
8−
9−Unit as argument
10−
11−Applies a function `b` that produces a unit to the unwrapped value of ++unit
12−`a` (`u.a`). If `a` is empty, `~` is produced.
13−
14−#### Accepts
15−
16−`a` is a unit.
17−
18−`b` is a function that accepts a noun and produces a unit.
19−
20−#### Produces
21−
22−A unit.
23−
24−#### Source
25−
26−```hoon
27− ++ biff
28− |* [a=(unit) b=$-(* (unit))]
29− ?~ a ~
30− (b u.a)
31−```
32−
33−#### Examples
34−
35−```
36− > (biff (some 5) |=(a=@ (some (add a 2))))
37− [~ u=7]
38−
39− > (biff ~ |=(a=@ (some (add a 2))))
40− ~
41−```
42−
43−
44−---
45−### `++bind`
46−
47−Non-unit function to unit, producing unit
48−
49−Applies a function `b` to the value (`u.a`) of a ++unit `a`, producing
50−a unit. Used when you want a function that does not accept or produce a
51−unit to both accept and produce a unit.
52−
53−#### Accepts
54−
55−`a` is a unit.
56−
57−`b` is a function.
58−
59−#### Produces
60−
61−A unit.
62−
63−#### Source
64−
65−```hoon
66− ++ bind
67− |* [a=(unit) b=gate]
68− ?~ a ~
69− [~ u=(b u.a)]
70−```
71−
72−
73−#### Examples
74−
75−```
76− > (bind ((unit @) [~ 97]) ,@t)
77− [~ u='a']
78−
79− > =a |=(a=@ (add a 1))
80− > (bind ((unit @) [~ 2]) a)
81− [~ u=3]
82−```
83−
84−
85−---
86−### `++bond`
87−
88−Replace null
89−
90−Replaces an empty ++unit `b` with the product of a called trap
91−`a`. If the unit is not empty, then the original unit is produced.
92−
93−#### Accepts
94−
95−`a` is a trap.
96−
97−`b` is a unit.
98−
99−#### Produces
100−
101−Either the product of `a` or the value inside of unit `b`.
102−
103−#### Source
104−
105−```hoon
106− ++ bond
107− |* a=(trap)
108− |* b=(unit)
109− ?~ b $:a
110− u.b
111−```
112−
113−#### Examples
114−
115−```
116− > (bex 10)
117− 1.024
118− > ((bond |.((bex 10))) ~)
119− 1.024
120−
121− > ((bond |.((bex 10))) (slaw %ud '123'))
122− 123
123−```
124−
125−
126−---
127−### `++both`
128−
129−Group unit values into pair
130−
131−Produces `~` if either `a` or `b` are empty. Otherwise, produces a
132−++unit whose value is a cell of the values of two input units `a` and
133−`b`.
134−
135−#### Accepts
136−
137−`a` is a unit.
138−
139−`b` is a unit.
140−
141−#### Produces
142−
143−A unit of the two initial values.
144−
145−#### Source
146−
147−```hoon
148− ++ both
149− |* [a=(unit) b=(unit)]
150− ?~ a ~
151− ?~ b ~
152− [~ u=[u.a u.b]]
153−```
154−
155−#### Examples
156−
157−```
158− > (both (some 1) (some %b))
159− [~ u=[1 %b]]
160−
161− > (both ~ (some %b))
162− ~
163−```
164−
165−---
166−### `++clap`
167−
168−Apply function to two units
169−
170−Applies a binary function `c`--which does not usually accept or produce a
171−`++unit`-- to the values of two units, `a` and `b`, producing a unit.
172−
173−#### Accepts
174−
175−`a` is a unit.
176−
177−`b` is a unit.
178−
179−`c` is a function that performs a binary operation.
180−
181−#### Produces
182−
183−A unit.
184−
185−#### Source
186−
187−```hoon
188− ++ clap :: combine
189− |* [a=(unit) b=(unit) c=_|=(^ +<-)]
190− ?~ a b
191− ?~ b a
192− [~ u=(c u.a u.b)]
193−```
194−
195−#### Examples
196−
197−```
198− > =u ((unit @t) [~ 'a'])
199− > =v ((unit @t) [~ 'b'])
200− > (clap u v |=([a=@t b=@t] (welp (trip a) (trip b))))
201− [~ u="ab"]
202−
203− > =a ((unit @u) [~ 1])
204− > =b ((unit @u) [~ 2])
205− > =c |=([a=@ b=@] (add a b))
206−
207− > (clap a b c)
208− [~ 3]
209−```
210−
211−
212−---
213−### `++drop`
214−
215−Unit to list
216−
217−Makes a ++list of the unwrapped value (`u.a`) of a `++unit` `a`.
218−
219−#### Accepts
220−
221−`a` is a unit.
222−
223−#### Produces
224−
225−A list.
226−
227−#### Source
228−
229−```hoon
230− ++ drop :: enlist
231− |* a=(unit)
232− ?~ a ~
233− [i=u.a t=~]
234−```
235−
236−#### Examples
237−
238−```
239− > =a ((unit @) [~ 97])
240− > (drop a)
241− [i=97 t=~]
242−
243− > =a ((unit @) [~])
244− > (drop a)
245− ~
246−```
247−
248−
249−---
250−### `++fall`
251−
252−Give unit a default value
253−
254−Produces a default value `b` for a `++unit` `a` in cases where `a` is null.
255−
256−#### Accepts
257−
258−`a` is a unit.
259−
260−`b` is a noun that's used as the default value.
261−
262−#### Produces
263−
264−Either a noun `b` or the unwrapped value of unit `a`.
265−
266−#### Source
267−
268−```hoon
269− ++ fall :: default
270− |* [a=(unit) b=*]
271− ?~(a b u.a)
272−```
273−
274−#### Examples
275−
276−```
277− > (fall ~ `a`)
278− `a`
279− > (fall [~ u=0] `a`)
280− 0
281−```
282−
283−---
284−### `++lift`
285−
286−Curried bind
287−
288−Accepts a `++gate` `a` and produces a function that accepts `++unit`
289−`b` to which it applies `a`. Used when you want a function that does not accept
290−or produce a unit to both accept and produce a unit.
291−
292−#### Accepts
293−
294−`a` is a gate.
295−
296−`b` is a unit.
297−
298−#### Produces
299−
300−A unit.
301−
302−#### Source
303−
304−```hoon
305− ++ lift :: lift gate (fmap)
306− |* a=gate :: flipped
307− |* b=(unit) :: curried
308− (bind b a) :: bind
309−```
310−
311−#### Examples
312−
313−```
314− > ((lift dec) `(unit @)`~)
315− ~
316−
317− > ((lift dec) `(unit @)`[~ 20])
318− [~ 19]
319−```
320−
321−
322−---
323−### `++mate`
324−
325−Choose
326−
327−Accepts two units `a` and `b` whose values are expected to be
328−equivalent. If either is empty, then the value of the other is produced.
329−If neither are empty, it asserts that both values are the same and
330−produces that value. If the assertion fails, `++mate` crashes with
331−`'mate'` in the stack trace.
332−
333−#### Accepts
334−
335−`a` is a unit.
336−
337−`b` is a unit.
338−
339−#### Produces
340−
341−A unit or crash.
342−
343−#### Source
344−
345−```hoon
346− ++ mate :: choose
347− |* [a=(unit) b=(unit)]
348− ?~ b a
349− ?~ a b
350− ?.(=(u.a u.b) ~|('mate' !!) a)
351−```
352−
353−#### Examples
354−
355−```
356− > =a ((unit @) [~ 97])
357− > =b ((unit @) [~ 97])
358− > (mate a b)
359− [~ 97]
360−
361− > =a ((unit @) [~ 97])
362− > =b ((unit @) [~])
363− > (mate a b)
364− [~ 97]
365−
366− > =a ((unit @) [~ 97])
367− > =b ((unit @) [~ 98])
368− > (mate a b)
369− ! 'mate'
370− ! exit
371−```
372−
373−
374−---
375−### `++need`
376−
377−Unwrap unit
378−
379−Retrieve the value from a `++unit` and crash if the unit is null.
380−
381−#### Accepts
382−
383−`a` is a unit.
384−
385−#### Produces
386−
387−Either the unwrapped value of `a` (`u.a`), or crash.
388−
389−#### Source
390−
391−```hoon
392− ++ need :: demand
393− |* a=(unit)
394− ?~ a ~|(%need !!)
395− u.a
396−```
397−
398−#### Examples
399−
400−```
401− > =a ((unit [@t @t]) [~ ['a' 'b']])
402− > (need a)
403− ['a' 'b']
404−
405− > =a ((unit @ud) [~ 17])
406− > (need a)
407− 17
408−
409− > =a ((unit @) [~])
410− > (need a)
411− ! exit
412−```
413−
414−
415−---
416−### `++some`
417−
418−Wrap value in a unit
419−
420−Takes any atom `a` and produces a `++unit` with the value set to `a`.
421−
422−#### Accepts
423−
424−`a` is a noun.
425−
426−#### Produces
427−
428−A unit.
429−
430−#### Source
431−
432−```hoon
433− ++ some :: lift (pure)
434− |* a=*
435− [~ u=a]
436−```
437−
438−#### Examples
439−
440−```
441− > (some [`a` `b`])
442− [~ u=[`a` `b`]]
443−
444− > (some &)
445− [~ u=%.y]
446−```
447−
448−
449−---
reference/library/2b.mddeleted−1293
@@ -1,1293 +0,0 @@
1−+++
2−title = "2b: List Logic"
3−weight = 5
4−template = "doc.html"
5−aliases = ["/docs/reference/library/2b"]
6−+++
7−### `++fand`
8−
9−All indices in `list`
10−
11−Produces the indices of all occurrences of `nedl` in `hstk` as a `list` of
12−atoms.
13−
14−#### Accepts
15−
16−`nedl` is a list.
17−
18−`hstk` is a list.
19−
20−#### Produces
21−
22−A `list`.
23−
24−#### Source
25−
26−```hoon
27− ++ fand
28− ~/ %fand
29− |= [nedl=(list) hstk=(list)]
30− =| i=@ud
31− =| fnd=(list @ud)
32− |- ^+ fnd
33− =+ [n=nedl h=hstk]
34− |-
35− ?: |(?=($~ n) ?=($~ h))
36− (flop fnd)
37− ?: =(i.n i.h)
38− ?~ t.n
39− ^$(i +(i), hstk +.hstk, fnd [i fnd])
40− $(n t.n, h t.h)
41− ^$(i +(i), hstk +.hstk)
42−```
43−
44−#### Examples
45−
46−```
47− > (fand ~[3] ~[1 2 3])
48− ~[2]
49−
50− > (fand ~[4] ~[1 2 3])
51− ~
52−
53− > (fand ~['a'] "cbabab")
54− ~[2 4]
55−
56− > (fand "ba" "cbabab")
57− ~[1 3]
58−```
59−
60−
61−---
62−### `++find`
63−
64−First index in `list`
65−
66−Produces the index of the first occurrence of `nedl` in `hstk` as the `unit`
67−of an atom.
68−
69−#### Accepts
70−
71−`nedl` is a list.
72−
73−`hstk` is a list.
74−
75−#### Produces
76−
77−The `unit` of an atom.
78−
79−#### Source
80−
81−```hoon
82− ++ find
83− ~/ %find
84− |= [nedl=(list) hstk=(list)]
85− =| i=@ud
86− |- ^- (unit @ud)
87− =+ [n=nedl h=hstk]
88− |-
89− ?: |(?=($~ n) ?=($~ h))
90− ~
91− ?: =(i.n i.h)
92− ?~ t.n
93− `i
94− $(n t.n, h t.h)
95− ^$(i +(i), hstk +.hstk)
96−```
97−
98−#### Examples
99−
100−```
101− > (find [3]~ ~[1 2 3])
102− [~ u=2]
103−
104− > (find [4]~ ~[1 2 3])
105− ~
106−
107− > (find ['c']~ "cbabab")
108− [~ u=0]
109−
110− > (find "ab" "cbabab")
111− [~ u=1]
112−
113− > (find "bab" "cbabab")
114− [~ u=2]
115−```
116−
117−---
118−### `++flop`
119−
120−Reverse
121−
122−Produces the `list` `a` in reverse order.
123−
124−#### Accepts
125−
126−`a` is a `list`.
127−
128−#### Produces
129−
130−A `list`.
131−
132−#### Source
133−
134−```hoon
135− ++ flop
136− ~/ %flop
137− |* a=(list)
138− => .(a (homo a))
139− ^+ a
140− =+ b=`_a`~
141− |-
142− ?~ a b
143− $(a t.a, b [i.a b])
144−```
145−
146−
147−#### Examples
148−
149−```
150− > =a [1 2 3 ~]
151− > (flop a)
152− ~[3 2 1]
153−
154− > (flop (flop a))
155− ~[1 2 3]
156−```
157−
158−---
159−### `++gulf`
160−
161−List from range
162−
163−Produces a `list` composed of each consecutive integer starting from `a` and
164−ending with `b`. `a` and `b` are themselves included.
165−
166−#### Accepts
167−
168−`a` is an atom.
169−
170−`b` is an atom.
171−
172−#### Produces
173−
174−a `list`.
175−
176−#### Source
177−
178−```hoon
179− ++ gulf
180− |= [a=@ b=@]
181− ^- (list @)
182− ?:(=(a +(b)) ~ [a $(a +(a))])
183−```
184−
185−#### Examples
186−
187−```
188− > (gulf 1 6)
189− ~[1 2 3 4 5 6]
190−
191− > `(list @t)`(gulf 99 106)
192− <|c d e f g h i j|>
193−```
194−
195−---
196−### `++homo`
197−
198−Homogenize
199−
200−Produces a `list` whose type is a fork of all the contained types in the
201−list `a`. Used when you want to make all the types of the elements of a list the
202−same.
203−
204−#### Accepts
205−
206−`a` is a `list`.
207−
208−#### Produces
209−
210−a `list`.
211−
212−#### Source
213−
214−```hoon
215− ++ homo
216− |* a=(list)
217− ^+ =< $
218− |% +- $ ?:(*? ~ [i=(snag 0 a) t=$])
219− --
220− a
221−```
222−
223−#### Examples
224−
225−```
226− > lyst
227− [i=1 t=[i=97 t=[i=2 t=[i=98 t=[i=[~ u=10] t=~]]]]]
228−
229− > (homo lyst)
230− ~[1 97 2 98 [~ u=10]]
231−
232− > =a (limo [1 2 3 ~])
233− > a
234− [i=1 t=[i=2 t=[i=3 t=~]]]
235−
236− > (homo a)
237− ~[1 2 3]
238−```
239−
240−---
241−
242−### `++join`
243−
244−Constructs a new `list`, placing `sep` between every element of `lit`.
245−
246−#### Accepts
247−
248−`sep` is a `noun`.
249−
250−`lit` is a `list`.
251−
252−#### Produces
253−
254−a `list`.
255−
256−#### Source
257−
258−```hoon
259− ++ join
260− |* [sep=* lit=(list)]
261− =. sep `_?>(?=(^ lit) i.lit)`sep
262− ?~ lit ~
263− =| out=(list _?>(?=(^ lit) i.lit))
264− |- ^+ out
265− ?~ t.lit
266− (flop [i.lit out])
267− $(out [sep i.lit out], lit t.lit)
268−```
269−
270−#### Examples
271−
272−```
273− > (join ' ' "hoon")
274− "h o o n"
275−
276− > (join 0 `(list @)`~[1 2 3])
277− ~[1 0 2 0 3]
278−```
279−
280−---
281−### `++lent`
282−
283−List length
284−
285−Produces the length of any `list` `a` as an atom.
286−
287−#### Accepts
288−
289−`a` is a `list`.
290−
291−#### Produces
292−
293−an atom.
294−
295−#### Source
296−
297−```hoon
298− ++ lent
299− ~/ %lent
300− |= a=(list)
301− ^- @
302− =+ b=0
303− |-
304− ?~ a b
305− $(a t.a, b +(b))
306−```
307−
308−#### Examples
309−
310−```
311− > (lent [1 2 3 4 ~]))
312− 4
313−
314− > (lent [1 'a' 2 'b' (some 10) ~])
315− 5
316−```
317−
318−
319−---
320−### `++levy`
321−
322−Logical "and" on list
323−
324−Computes the Boolean logical "and" on the results of gate `b` applied to each individual element in `list` `a`.
325−
326−#### Accepts
327−
328−`a` is a list.
329−
330−`b` is a gate.
331−
332−#### Produces
333−
334−A boolean.
335−
336−#### Source
337−
338−```hoon
339− ++ levy
340− ~/ %levy :: all of
341− |* [a=(list) b=$-(* ?)]
342− |- ^- ?
343− ?~ a &
344− ?. (b i.a) |
345− $(a t.a)
346−```
347−
348−#### Examples
349−
350−```
351− > =a |=(a=@ (lte a 1))
352− > (levy `(list @)`[0 1 2 1 ~] a)
353− %.n
354−
355− > =a |=(a=@ (lte a 3))
356− > (levy `(list @)`[0 1 2 1 ~] a)
357− %.y
358−```
359−
360−
361−---
362−
363−### `++lien`
364−
365−Logical "or" on list
366−
367−Computes the Boolean logical "or" on the results of applying `gate` `b` to
368−every element of `++list` `a`.
369−
370−#### Accepts
371−
372−`a` is a list.
373−
374−`b` is a gate.
375−
376−#### Source
377−
378−```hoon
379− ++ lien
380− ~/ %lien
381− |* [a=(list) b=$-(* ?)]
382− |- ^- ?
383− ?~ a |
384− ?: (b i.a) &
385− $(a t.a)
386−```
387−
388−#### Examples
389−
390−```
391− > =a |=(a=@ (gte a 1))
392− > (lien `(list @)`[0 1 2 1 ~] a)
393− %.y
394−
395− > =a |=(a=@ (gte a 3))
396− > (lien `(list @)`[0 1 2 1 ~]) a)
397− %.n
398−```
399−
400−
401−---
402−### `++limo`
403−
404−List Constructor
405−
406−Turns a null-terminated tuple into a `list`.
407−
408−#### Accepts
409−
410−`a` is a null-terminated tuple.
411−
412−#### Produces
413−
414−A `++list`.
415−
416−#### Source
417−
418−```hoon
419− ++ limo :: listify
420− |* a=*
421− ^+ =< $
422− |% +- $ ?~(a ~ ?:(_? i=-.a t=$ $(a +.a)))
423− --
424− a
425−```
426−
427−#### Examples
428−
429−```
430− > (limo [1 2 3 ~])
431− [i=1 t=[i=2 t=[i=3 t=~]]]
432−```
433−
434−
435−---
436−### `++murn`
437−
438−Maybe transform
439−
440−Passes each member of `list` `a` to gate `b`, which must produce a
441−`unit`. Produces a new list with all the results that do not produce
442−`~`.
443−
444−#### Accepts
445−
446−`a` is a list.
447−
448−`b` is a gate that produces a unit.
449−
450−#### Produces
451−
452−A unit.
453−
454−#### Source
455−
456−```hoon
457− ++ murn :: maybe transform
458− ~/ %murn
459− |* [a=(list) b=$-(* (unit))]
460− |-
461− ?~ a ~
462− =+ c=(b i.a)
463− ?~ c
464− $(a t.a)
465− [i=u.c t=$(a t.a)]
466−```
467−
468−#### Examples
469−
470−```
471− > =a |=(a=@ ?.((gte a 2) ~ (some (add a 10))))
472− > (murn `(list @)`[0 1 2 3 ~] a)
473− [i=12 t=[i=13 t=~]]
474−```
475−
476−
477−---
478−### `++oust`
479−
480−Remove
481−
482−Removes elements from list `c` beginning at inclusive index `a`, removing `b`
483−number of elements.
484−
485−#### Accepts
486−
487−`c` is a list.
488−
489−#### Produces
490−
491−A `++list`.
492−
493−#### Source
494−
495−```hoon
496− ++ oust :: remove
497− ~/ %oust
498− |* [[a=@ b=@] c=(list)]
499− (weld (scag a c) (slag (add a b) c))
500−```
501−
502−#### Examples
503−
504−```
505− > (oust [4 5] "good day, urbit!")
506− "good urbit!"
507−
508− > (oust [2 2] `(list @)`[1 2 3 4 ~])
509− ~[1 2]
510−```
511−
512−
513−---
514−### `++reap`
515−
516−Replicate
517−
518−Replicate: produces a `list` containing `a` copies of `b`.
519−
520−#### Accepts
521−
522−`a` is an atom.
523−
524−`b` is a noun.
525−
526−#### Produces
527−
528−A list.
529−
530−#### Source
531−
532−```hoon
533− ++ reap :: replicate
534− ~/ %reap
535− |* [a=@ b=*]
536− |- ^- (list _b)
537− ?~ a ~
538− [b $(a (dec a))]
539−```
540−
541−#### Examples
542−
543−```
544− > (reap 20 %a)
545− ~[%a %a %a %a %a %a %a %a %a %a %a %a %a %a %a %a %a %a %a %a]
546−
547− > (reap 5 ~s1)
548− ~[~s1 ~s1 ~s1 ~s1 ~s1]
549−
550− > `@dr`(roll (reap 5 ~s1) add)
551− ~s5
552−```
553−
554−
555−---
556−### `++reel`
557−
558−Right fold
559−
560−Right fold: moves right to left across a `list` `a`, recursively slamming
561−a binary gate `b` with an element from `a` and an accumulator, producing
562−the final value of the accumulator.
563−
564−(To "slam" means to call a gate and give it a sample/samples. In this instance,
565−`a` is the list of samples that are given to the gate b.)
566−
567−#### Accepts
568−
569−`a` is a list.
570−
571−`b` is a binary gate.
572−
573−#### Produces
574−
575−The accumulator, which is a noun.
576−
577−#### Source
578−
579−```hoon
580− ++ reel
581− ~/ %reel
582− |* [a=(list) b=_|=([* *] +<+)]
583− |- ^+ +<+.b
584− ?~ a
585− +<+.b
586− (b i.a $(a t.a))
587−```
588−
589−#### Examples
590−
591−```
592− > =sum =|([p=@ q=@] |.((add p q)))
593− > (reel (limo [1 2 3 4 5 ~]) sum)
594− 15
595−
596− > =a =|([p=@ q=@] |.((sub p q)))
597− > (reel (limo [6 3 1 ~]) a)
598− 4
599−
600− > (reel (limo [3 6 1 ~]) a)
601− ! subtract-underflow
602− ! exit
603−```
604−
605−
606−---
607−### `++roll`
608−
609−Left fold
610−
611−Left fold: moves left to right across a list `a`, recursively slamming a
612−binary gate `b` with an element from the `list` and an accumulator,
613−producing the final value of the accumulator.
614−
615−(To "slam" means to call a gate and give it a sample/samples. In this instance,
616−`a` is the list of samples that are given to the gate b.)
617−
618−#### Accepts
619−
620−`a` is a list.
621−
622−`b` is a binary gate.
623−
624−#### Produces
625−
626−The accumulator, which is a noun.
627−
628−#### Source
629−
630−```hoon
631− ++ roll :: left fold
632− ~/ %roll
633− |* [a=(list) b=_|=([* *] +<+)]
634− |- ^+ +<+.b
635− ?~ a
636− +<+.b
637− $(a t.a, b b(+<+ (b i.a +<+.b)))
638−```
639−
640−#### Examples
641−
642−```
643− > =sum =|([p=@ q=@] |.((add p q)))
644− > (roll (limo [1 2 3 4 5 ~]) sum)
645− q=15
646−
647− > =a =|([p=@ q=@] |.((sub p q)))
648− > (roll (limo [6 3 1 ~]) a)
649− ! subtract-underflow
650− ! exit
651−
652− > (roll (limo [1 3 6 ~]) a)
653− q=4
654−```
655−
656−
657−---
658−### `++scag`
659−
660−Prefix
661−
662−Accepts an atom `a` and `list` `b`, producing the first `a` elements of
663−the front of the list.
664−
665−#### Accepts
666−
667−`a` is an atom.
668−
669−`b` is a list.
670−
671−#### Produces
672−
673−A list of the same type as `b`.
674−
675−#### Source
676−
677−```hoon
678− ++ scag :: prefix
679− ~/ %scag
680− |* [a=@ b=(list)]
681− |- ^+ b
682− ?: |(?=(~ b) =(0 a)) ~
683− [i.b $(b t.b, a (dec a))]
684−```
685−
686−#### Examples
687−
688−```
689− > (scag 2 `(list @)`[1 2 3 4 ~])
690− [i=1 t=~[2]]
691−
692− > (scag 10 `(list @)`[1 2 3 4 ~])
693− [i=1 t=~[2 3 4]]
694−```
695−
696−
697−---
698−### `++skid`
699−
700−Separate
701−
702−Separates a `list` `a` into two lists - Those elements of `a` who produce
703−true when slammed to gate `b` and those who produce `%.n`.
704−
705−(To "slam" means to call a gate and give it a sample/samples. In this instance,
706−`a` is the list of samples that are given to the gate `b`.)
707−
708−#### Accepts
709−
710−`a` is a list.
711−
712−`b` is a gate that accepts one argument and produces a flag.
713−
714−#### Produces
715−
716−A cell of two lists.
717−
718−#### Source
719−
720−```hoon
721− ++ skid :: separate
722− ~/ %skid
723− |* [a=(list) b=$-(* ?)]
724− |- ^+ [p=a q=a]
725− ?~ a [~ ~]
726− =+ c=$(a t.a)
727− ?:((b i.a) [[i.a p.c] q.c] [p.c [i.a q.c]])
728−```
729−
730−
731−#### Examples
732−
733−```
734− > =a |=(a=@ (gth a 1))
735− > (skid `(list @)`[0 1 2 3 ~]) a)
736− (skid `(list @)`[0 1 2 3 ~]) a)
737−```
738−
739−
740−---
741−### `++skim`
742−
743−Suffix
744−
745−Cycles through the members of a list `a`, passing them to a gate `b` and
746−producing a list of all of the members that produce `%.y`. Inverse of
747−`skip`.
748−
749−#### Accepts
750−
751−`a` is a list.
752−
753−`b` is a gate that accepts one argument and produces a boolean.
754−
755−#### Produces
756−
757−A flag.
758−
759−#### Source
760−
761−```hoon
762− ++ skim :: only
763− ~/ %skim
764− |* [a=(list) b=$-(* ?)]
765− |-
766− ^+ a
767− ?~ a ~
768− ?:((b i.a) [i.a $(a t.a)] $(a t.a))
769−```
770−
771−#### Examples
772−
773−```
774− > =a |=(a=@ (gth a 1))
775− > (skim `(list @)`[0 1 2 3 ~] a)
776− [i=2 t=~[3]]
777−```
778−
779−---
780−### `++skip`
781−
782−Except
783−
784−Cycles through the members of `list` `a`, passing them to a gate `b`.
785−Produces a list of all of the members that produce `%.n`. Inverse of
786−`skim`.
787−
788−#### Accepts
789−
790−`a` is a list.
791−
792−`b` is a gate that accepts one argument and produces a flag.
793−
794−#### Produces
795−
796−A list of the same type as `a`.
797−
798−#### Source
799−
800−```hoon
801− ++ skip :: except
802− ~/ %skip
803− |* [a=(list) b=$-(* ?)]
804− |-
805− ^+ a
806− ?~ a ~
807− ?:((b i.a) $(a t.a) [i.a $(a t.a)])
808−```
809−
810−#### Examples
811−
812−```
813− > =a |=(a=@ (gth a 1))
814− > (skip `(l)`[0 1 2 3 ~]) a)
815− [i=0 t=[i=1 t=~]]
816−```
817−
818−
819−---
820−### `++slag`
821−
822−Suffix
823−
824−Accepts an atom `a` and list `b`, producing the remaining elements from
825−`b` starting at `a`.
826−
827−#### Accepts
828−
829−`a` is an atom.
830−
831−`b` is a list.
832−
833−#### Produces
834−
835−A list of the same type as `b`.
836−
837−#### Source
838−
839−```hoon
840− ++ slag :: suffix
841− ~/ %slag
842− |* [a=@ b=(list)]
843− |- ^+ b
844− ?: =(0 a) b
845− ?~ b ~
846− $(b t.b, a (dec a))
847−```
848−
849−#### Examples
850−
851−```
852− > (slag 2 (limo [1 2 3 4 ~]))
853− [i=3 t=[i=4 t=~]]
854− > (slag 1 (limo [1 2 3 4 ~]))
855− [i=2 t=[i=3 t=[i=4 t=~]]]
856−```
857−
858−
859−---
860−### `++snag`
861−
862−Index
863−
864−Accepts an atom `a` and a `++list` `b`, producing the element at the index
865−of `a`and failing if the list is null. Lists are 0-indexed.
866−
867−#### Accepts
868−
869−`a` is an atom.
870−
871−`b` is a list.
872−
873−#### Produces
874−
875−Produces an element of `b`, or crashes if no element exists at that index.
876−
877−#### Source
878−
879−```hoon
880− ++ snag :: index
881− ~/ %snag
882− |* [a=@ b=(list)]
883− |-
884− ?~ b
885− ~|('snag-fail' !!)
886− ?: =(0 a) i.b
887− $(b t.b, a (dec a))
888−```
889−
890−#### Examples
891−
892−```
893− > (snag 2 "asdf")
894− ~~d
895− > (snag 0 `(list @ud)`~[1 2 3 4])
896− 1
897−```
898−
899−
900−---
901−### `++snoc`
902−
903−Append
904−
905−Accepts a `++list` `a` and a noun `b`, producing the list of `b` appended to `a`.
906−
907−#### Accepts
908−
909−`a` is a list.
910−
911−`b` is a noun.
912−
913−#### Produces
914−
915−Produces a list of `b` appended to `a`.
916−
917−#### Source
918−
919−```hoon
920− ++ snoc
921− |* [a/(list) b/*]
922− (weld a ^+(a [b]~))
923−```
924−
925−#### Examples
926−
927−```
928− > `tape`(zing (snoc `(list tape)`~["a" "bc" "def"] "g"))
929− "abcdefg"
930− > (snoc `(list @ud)`~[1 2 3] 4)
931− ~[1 2 3 4]
932−```
933−
934−
935−---
936−### `++sort`
937−
938−Quicksort
939−
940−Quicksort: accepts a `++list` `a` and a gate `b` which accepts two nouns and
941−produces a flag. `++sort` then produces a list of the elements of `a`,
942−sorted according to `b`.
943−
944−#### Accepts
945−
946−`a` is a list.
947−
948−`b` is a gate that accepts two nouns and produces a boolean.
949−
950−#### Produces
951−
952−A list
953−
954−#### Source
955−
956−```hoon
957− ++ sort !. :: quicksort
958− ~/ %sort
959− |* [a=(list) b=$-([* *] ?)]
960− => .(a ^.(homo a))
961− |- ^+ a
962− ?~ a ~
963− %+ weld
964− $(a (skim t.a |=(c/_i.a (b c i.a))))
965− ^+ t.a
966− [i.a $(a (skim t.a |=(c/_i.a !(b c i.a))))]
967−```
968−
969−#### Examples
970−
971−```
972− > =a =|([p/@ q/@] |.((gth p q)))
973− > (sort (limo [0 1 2 3 ~]) a)
974− ~[3 2 1 0]
975−```
976−
977−
978−---
979−### `++spin`
980−
981−Gate to list, with state
982−
983−Accepts a `++list` `a`, a gate `b`, and some state `c`. Produces a list with
984−the gate applied to each element of the original list. `b` is called with
985−a tuple -- the head is an element of `a` and the tail is the state `c`, and
986−should produce a tuple of the transformed element and the (potentially
987−modified) state `c`.
988−
989−#### Accepts
990−
991−`a` is a `++list`.
992−
993−`b` is a gate.
994−
995−`c` is a noun.
996−
997−#### Produces
998−
999−A list.
1000−
1001−#### Source
1002−
1003−```hoon
1004− ++ spin
1005− ~/ %spin
1006− |* [a=(list) b=* c=_|=(^ [** +<+])]
1007− => .(c `$-([_?>(?=(^ a) i.a) _b] [_-:(c) _b])`c)
1008− =/ acc=(list _-:(c)) ~
1009− |- ^- (pair _acc _b)
1010− ?~ a
1011− [(flop acc) b]
1012− =^ res b (c i.a b)
1013− $(acc [res acc], a t.a)
1014−```
1015−
1016−#### Examples
1017−
1018−```
1019− > %^ spin (limo ~[4 5 6]) :: trivial example -- does nothing with the state
1020− |=([n=@ a=@] [n a])
1021− 0
1022− ~[4 5 6]
1023−
1024− > %^ spin (limo ~[4 5 6]) :: `p` as the index and `q` as the list element
1025− |=([n=@ a=@] [`(pair)`[a n] +(a)])
1026− 0
1027− ~[[p=0 q=4] [p=1 q=5] [p=2 q=6]]
1028−
1029− > %^ spin (reap 10 0) :: Create 10 random numbers less than `10`
1030− |=([n=@ rng=_og] (rads:rng 10))
1031− ~(. og eny)
1032− ~[5 5 9 4 1 7 9 9 9 6]
1033−```
1034−
1035−#### Discussion
1036−
1037−`(~(rads og eny) 2)` creates a random number less than `2`, seeding the RNG
1038−with entropy (`eny`). The head of the product is the random number, the tail
1039−is the continuation of the RNG.
1040−
1041−
1042−
1043−---
1044−### `++spun`
1045−
1046−Gate to list, with state
1047−
1048−Accepts a `list` `a` and a gate `b`. `c` is internal state, initially
1049−derived by **bunting** the tail of the sample of gate `b`, instead of
1050−being passed in explicitly as in `++spin`. Produces a list with the
1051−gate applied to each element of the original list. `b` is called with a tuple --
1052−the head is an element of `a` and the tail is the state `c`, and should
1053−produce a tuple of the transformed element and the (potentially modified)
1054−state `c`.
1055−
1056−#### Accepts
1057−
1058−`a` is a `++list`.
1059−
1060−`b` is a gate.
1061−
1062−#### Produces
1063−
1064−A list.
1065−
1066−#### Source
1067−
1068−```hoon
1069− ++ spun
1070− ~/ %spun
1071− |* [a=(list) b=_|=(^ [** +<+])]
1072− p:(spin a +<+.b b)
1073−```
1074−
1075−#### Examples
1076−
1077−```
1078− > %+ spun (limo ~[4 5 6]) :: `p` as the index and `q` as the list element
1079− |=([n=@ a=@] [`(pair)`[a n] +(a)])
1080− ~[[p=0 q=4] [p=1 q=5] [p=2 q=6]]
1081−
1082− > =l (limo ~[7 8 9])
1083− > %+ spun (limo ~[4 5 6]) :: joins two lists into a list of pairs
1084− |=([n=@ a=@] [`(pair)`[(snag a l) n] +(a)])
1085− ~[[p=7 q=4] [p=8 q=5] [p=9 q=6]]
1086−```
1087−
1088−
1089−---
1090−### `++swag`
1091−
1092−Infix
1093−
1094−Similar to `substr` in Javascript: extracts a string infix, beginning at
1095−inclusive index `a`, producing `b` number of characters.
1096−
1097−#### Accepts
1098−
1099−`a` is an atom.
1100−
1101−`b` is an atom.
1102−
1103−`c` is a list.
1104−
1105−#### Produces
1106−
1107−A list of the same type as `c`.
1108−
1109−#### Source
1110−
1111−```hoon
1112− ++ swag
1113− |* [[a=@ b=@] c=(list)]
1114− (scag +<-> (slag +<-< c))
1115−```
1116−
1117−#### Examples
1118−
1119−```
1120− > (swag [2 5] "roly poly")
1121− "ly po"
1122−
1123− > (swag [2 2] (limo [1 2 3 4 ~]))
1124− [i=3 t=[i=4 t=~]]
1125−```
1126−
1127−
1128−---
1129−### `++turn`
1130−
1131−Gate to list
1132−
1133−Accepts a `++list` `a` and a gate `b`. Produces a list with the gate applied
1134−to each element of the original list.
1135−
1136−#### Accepts
1137−
1138−`a` is a list.
1139−
1140−`b` is a gate.
1141−
1142−#### Produces
1143−
1144−A list.
1145−
1146−#### Source
1147−
1148−```hoon
1149− ++ turn
1150− ~/ %turn
1151− |* [a=(list) b=gate]
1152− |-
1153− ?~ a ~
1154− [i=(b i.a) t=$(a t.a)]
1155−```
1156−
1157−#### Examples
1158−
1159−```
1160− > (turn (limo [104 111 111 110 ~]) @t)
1161− <|h o o n|>
1162−
1163− > =a |=(a=@ (add a 4))
1164− > (turn (limo [1 2 3 4 ~]) a)
1165− ~[5 6 7 8]
1166−```
1167−
1168−#### Discussion
1169−
1170−`turn` is Hoon's version of 'map' in Haskell.
1171−
1172−---
1173−### `++weld`
1174−
1175−Concatenate
1176−
1177−Concatenate two `++list`s `a` and `b`.
1178−
1179−#### Accepts
1180−
1181−`a` and `b` are lists.
1182−
1183−#### Source
1184−
1185−```hoon
1186− ++ weld
1187− ~/ %weld
1188− |* [a=(list) b=(list)]
1189− => .(a ^.(homo a), b ^.(homo b))
1190− |- ^+ b
1191− ?~ a b
1192− [i.a $(a t.a)]
1193−```
1194−
1195−#### Examples
1196−
1197−```
1198− > (weld "urb" "it")
1199− ~[~~u ~~r ~~b ~~i ~~t]
1200−
1201− > (weld (limo [1 2 ~]) (limo [3 4 ~]))
1202− ~[1 2 3 4]
1203−```
1204−
1205−
1206−---
1207−### `++welp`
1208−
1209−Perfect weld
1210−
1211−Concatenate two `++list`s `a` and `b` without losing their type information
1212−to homogenization.
1213−
1214−#### Accepts
1215−
1216−`a` is a list.
1217−
1218−`b` is a list.
1219−
1220−#### Produces
1221−
1222−A list.
1223−
1224−#### Source
1225−
1226−```hoon
1227− ++ welp
1228− =| [* *]
1229− |%
1230− +- $
1231− ?~ +<-
1232− +<-(. +<+)
1233− +<-(+ $(+<- +<->))
1234− --
1235−```
1236−
1237−#### Examples
1238−
1239−```
1240− > (welp "foo" "bar")
1241− "foobar"
1242−
1243− > (welp ~[60 61 62] ~[%a %b %c])
1244− [60 61 62 %a %b %c ~]
1245−
1246− > ? (welp ~[60 61 62] ~[%a %b %c])
1247− {@ud @ud @ud $a $b $c $~}
1248− [60 61 62 %a %b %c ~]
1249−
1250− > (welp [sa+1 so+2 ~] si=3)
1251− [[%sa 1] [%so 2] si=3]
1252−```
1253−
1254−
1255−---
1256−### `++zing`
1257−
1258−Turns a `++list` of lists into a single list by promoting the elements of
1259−each sublist into the higher.
1260−
1261−#### Accepts
1262−
1263−A list of lists.
1264−
1265−#### Produces
1266−
1267−A list.
1268−
1269−#### Source
1270−
1271−```hoon
1272− ++ zing
1273− =| *
1274− |%
1275− +- $
1276− ?~ +<
1277− +<
1278− (welp +<- $(+< +<+))
1279− --
1280−```
1281−
1282−
1283−#### Examples
1284−
1285−```
1286− > (zing (limo [(limo ['a' 'b' 'c' ~]) (limo ['e' 'f' 'g' ~]) (limo ['h' 'i' 'j' ~]) ~]))
1287− ~['a' 'b' 'c' 'e' 'f' 'g' 'h' 'i' 'j']
1288−
1289− > (zing (limo [(limo [1 'a' 2 'b' ~]) (limo [3 'c' 4 'd' ~]) ~]))
1290− ~[1 97 2 98 3 99 4 100]
1291−```
1292−
1293−---
reference/library/2c.md+23−23
@@ -20,7 +20,7 @@ An atom.
2020
2121#### Source
2222
23−```hoon
23+```reference
2424 ++ bex
2525 ~/ %bex
2626 |= a=@
@@ -63,7 +63,7 @@ An atom.
6363
6464#### Source
6565
66−```hoon
66+```reference
6767 ++ can
6868 ~/ %can
6969 |= [a=bloq b=(list [p=@ q=@])]
@@ -122,7 +122,7 @@ An atom.
122122
123123#### Source
124124
125−```hoon
125+```reference
126126 ++ cat
127127 ~/ %cat
128128 |= [a=bloq b=@ c=@]
@@ -187,7 +187,7 @@ An atom.
187187
188188#### Source
189189
190−```hoon
190+```reference
191191 ++ cut
192192 ~/ %cut
193193 |= [a=bloq [b=@u c=@u] d=@]
@@ -245,7 +245,7 @@ An atom.
245245
246246#### Source
247247
248−```hoon
248+```reference
249249 ++ end
250250 ~/ %end
251251 |= [a=bloq b=@u c=@]
@@ -311,7 +311,7 @@ An atom.
311311
312312#### Source
313313
314−```hoon
314+```reference
315315 ++ fil
316316 |= [a=bloq b=@u c=@]
317317 =+ n=0
@@ -363,7 +363,7 @@ An atom.
363363
364364#### Source
365365
366−```hoon
366+```reference
367367 ++ lsh
368368 ~/ %lsh
369369 |= [a=bloq b=@u c=@]
@@ -408,7 +408,7 @@ Computes the number of blocks of size `a` in `b`, producing an atom.
408408
409409#### Source
410410
411−```hoon
411+```reference
412412 ++ met
413413 ~/ %met
414414 |= [a=bloq b=@]
@@ -458,7 +458,7 @@ An atom.
458458
459459#### Source
460460
461−```hoon
461+```reference
462462 ++ rap
463463 ~/ %rap
464464 |= [a=bloq b=(list @)]
@@ -519,7 +519,7 @@ An atom.
519519
520520#### Source
521521
522−```hoon
522+```reference
523523 ++ rep
524524 ~/ %rep
525525 |= [a=bloq b=(list @)]
@@ -584,7 +584,7 @@ A list of atoms.
584584
585585#### Source
586586
587−```hoon
587+```reference
588588 ++ rip
589589 ~/ %rip
590590 |= [a=bloq b=@]
@@ -646,7 +646,7 @@ An atom.
646646
647647#### Source
648648
649−```hoon
649+```reference
650650 ++ rsh
651651 ~/ %rsh
652652 |= [a=bloq b=@u c=@]
@@ -712,7 +712,7 @@ An atom
712712
713713#### Source
714714
715−```hoon
715+```reference
716716 ++ swp |=([a=bloq b=@] (rep a (flop (rip a b))))
717717```
718718
@@ -753,7 +753,7 @@ An atom.
753753
754754#### Source
755755
756−```hoon
756+```reference
757757 ++ xeb
758758 ~/ %xeb
759759 |= a=@
@@ -797,7 +797,7 @@ Core that contains arms for `bloq` and modular integer operations.
797797
798798#### Source
799799
800−```hoon
800+```reference
801801 |_ a=bloq
802802```
803803
@@ -821,7 +821,7 @@ A `@s`
821821
822822#### Source
823823
824−```hoon
824+```reference
825825 ++ dif |=([b=@ c=@] (sit (sub (add out (sit b)) (sit c))))
826826```
827827
@@ -870,7 +870,7 @@ An atom.
870870
871871#### Source
872872
873−```hoon
873+```reference
874874 ++ inv |=(b=@ (sub (dec out) (sit b)))
875875```
876876
@@ -913,7 +913,7 @@ An atom.
913913
914914#### Source
915915
916−```hoon
916+```reference
917917 ++ net |= b=@ ^- @
918918 => .(b (sit b))
919919 ?: (lte a 3)
@@ -1002,7 +1002,7 @@ An atom.
10021002
10031003#### Source
10041004
1005−```hoon
1005+```reference
10061006 ++ out (bex (bex a))
10071007```
10081008
@@ -1057,7 +1057,7 @@ An atom.
10571057
10581058#### Source
10591059
1060−```hoon
1060+```reference
10611061 ++ rol |= [b=bloq c=@ d=@] ^- @
10621062 =+ e=(sit d)
10631063 =+ f=(bex (sub a b))
@@ -1107,7 +1107,7 @@ An atom.
11071107
11081108#### Source
11091109
1110−```hoon
1110+```reference
11111111 ++ ror |= [b=bloq c=@ d=@] ^- @
11121112 =+ e=(sit d)
11131113 =+ f=(bex (sub a b))
@@ -1156,7 +1156,7 @@ An atom.
11561156
11571157#### Source
11581158
1159−```hoon
1159+```reference
11601160 ++ sit |=(b=@ (end a 1 b))
11611161```
11621162
@@ -1219,7 +1219,7 @@ An atom.
12191219
12201220#### Source
12211221
1222−```hoon
1222+```reference
12231223 ++ sum |=([b=@ c=@] (sit (add b c)))
12241224```
12251225
reference/library/2d.md+4−4
@@ -22,7 +22,7 @@ An atom.
2222
2323#### Source
2424
25−```hoon
25+```reference
2626 ++ con
2727 ~/ %con
2828 |= [a=@ b=@]
@@ -117,7 +117,7 @@ An atom.
117117
118118#### Source
119119
120−```hoon
120+```reference
121121 ++ dis
122122 ~/ %dis
123123 |= [a=@ b=@]
@@ -205,7 +205,7 @@ An atom.
205205
206206#### Source
207207
208−```hoon
208+```reference
209209 ++ mix
210210 ~/ %mix
211211 |= [a=@ b=@]
@@ -293,7 +293,7 @@ An atom.
293293
294294#### Source
295295
296−```hoon
296+```reference
297297 ++ not |= [a=bloq b=@ c=@]
298298 (mix c (dec (bex (mul b (bex a)))))
299299```
reference/library/2e.md+4−4
@@ -22,7 +22,7 @@ An atom.
2222
2323#### Source
2424
25−```hoon
25+```reference
2626 ++ fnv |=(a=@ (end 5 1 (mul 16.777.619 a)))
2727```
2828
@@ -58,7 +58,7 @@ An atom.
5858
5959#### Source
6060
61−```hoon
61+```reference
6262 ++ mug
6363 ~/ %mug
6464 |= a=*
@@ -125,7 +125,7 @@ An atom.
125125
126126#### Source
127127
128−```hoon
128+```reference
129129 ++ muk
130130 ~% %muk ..muk ~
131131 =+ ~(. fe 5)
@@ -236,7 +236,7 @@ An atom.
236236
237237#### Source
238238
239−```hoon
239+```reference
240240 ++ mum
241241 ~/ %mum
242242 |= a=*
reference/library/2f.md+6−6
@@ -22,7 +22,7 @@ A flag.
2222
2323#### Source
2424
25−```hoon
25+```reference
2626 ++ aor
2727 ~/ %aor
2828 |= [a=* b=*]
@@ -92,7 +92,7 @@ A flag.
9292
9393#### Source
9494
95−```hoon
95+```reference
9696 ++ dor
9797 ~/ %dor
9898 |= [a=* b=*]
@@ -162,7 +162,7 @@ A flag.
162162
163163#### Source
164164
165−```hoon
165+```reference
166166 ++ gor
167167 ~/ %gor
168168 |= [a=* b=*]
@@ -243,7 +243,7 @@ A flag.
243243
244244#### Source
245245
246−```hoon
246+```reference
247247 ++ hor
248248 ~/ %hor
249249 |= [a=* b=*]
@@ -320,7 +320,7 @@ A flag.
320320
321321#### Source
322322
323−```hoon
323+```reference
324324 ++ lor
325325 ~/ %lor
326326 |= [a=* b=*]
@@ -393,7 +393,7 @@ A flag.
393393
394394#### Source
395395
396−```hoon
396+```reference
397397 ++ vor
398398 ~/ %vor
399399 |= [a=* b=*]
reference/library/2g.mddeleted−105
@@ -1,105 +0,0 @@
1−+++
2−title = "2g: Unsigned Powers"
3−weight = 10
4−template = "doc.html"
5−aliases = ["/docs/reference/library/2g"]
6−+++
7−### `++pow`
8−
9−Computes `a` raised to the power of `b`, producing an atom.
10−
11−#### Accepts
12−
13−`a` is an atom.
14−
15−`b` is an atom.
16−
17−#### Produces
18−
19−An atom.
20−
21−#### Source
22−
23−```hoon
24− ++ pow
25− ~/ %pow
26− |= [a=@ b=@]
27− ?: =(b 0) 1
28− |- ?: =(b 1) a
29− =+ c=$(b (div b 2))
30− =+ d=(mul c c)
31− ?~ (dis b 1) d (mul d a)
32−```
33−
34−#### Examples
35−
36−```
37− > (pow 2 6)
38− 64
39−
40− > (pow 6 2)
41− 36
42−
43− > (pow 7 (add 2 2))
44− 2.401
45−
46− > (pow 2 0)
47− 1
48−
49− > `@ux`(pow 0x1b 2)
50− 0x2d9
51−```
52−
53−---
54−### `++sqt`
55−
56−Computes the square root of `a` and its remainder.
57−
58−#### Accepts
59−
60−`a` is an atom.
61−
62−#### Produces
63−
64−A cell of atoms.
65−
66−#### Source
67−
68−```hoon
69− ++ sqt
70− ~/ %sqt
71− |= a=@ ^- [p=@ q=@]
72− ?~ a [0 0]
73− =+ [q=(div (dec (xeb a)) 2) r=0]
74− =- [-.b (sub a +.b)]
75− ^= b |-
76− =+ s=(add r (bex q))
77− =+ t=(mul s s)
78− ?: =(q 0)
79− ?:((lte t a) [s t] [r (mul r r)])
80− ?: (lte t a)
81− $(r s, q (dec q))
82− $(q (dec q))
83−```
84−
85−#### Examples
86−
87−```
88− > (sqt 4)
89− [p=2 q=0]
90−
91− > (sqt 6)
92− [p=2 q=2]
93−
94− > (sqt 2)
95− [p=1 q=1]
96−
97− > (sqt 0b1101)
98− [p=3 q=4]
99−
100− > `@ux`(sqt 0b1101)
101− ! exit
102−```
103−
104−
105−---
reference/library/2h.md+17−17
@@ -17,7 +17,7 @@ A `set`.
1717
1818#### Source
1919
20−```hoon
20+```reference
2121 ++ in
2222 ~/ %in
2323 |_ a=(set)
@@ -49,7 +49,7 @@ A flag.
4949
5050#### Source
5151
52−```hoon
52+```reference
5353 +- all
5454 ~/ %all
5555 |* b=$-(* ?)
@@ -91,7 +91,7 @@ A flag.
9191
9292#### Source
9393
94−```hoon
94+```reference
9595 +- any
9696 ~/ %any
9797 |* b=$-(* ?)
@@ -131,7 +131,7 @@ A flag.
131131
132132#### Source
133133
134−```hoon
134+```reference
135135 +- apt
136136 =| [l=(unit) r=(unit)]
137137 |- ^- ?
@@ -185,7 +185,7 @@ A cell of two sets.
185185
186186#### Source
187187
188−```hoon
188+```reference
189189 +- bif
190190 ~/ %bif
191191 |* b=*
@@ -238,7 +238,7 @@ A set.
238238
239239#### Source
240240
241−```hoon
241+```reference
242242 +- del
243243 ~/ %del
244244 |* b=*
@@ -293,7 +293,7 @@ A set.
293293
294294#### Source
295295
296−```hoon
296+```reference
297297 +- dif
298298 ~/ %dif
299299 |* b=_a
@@ -348,7 +348,7 @@ The `unit` of an atom.
348348
349349#### Source
350350
351−```hoon
351+```reference
352352 +- dig
353353 |= b=*
354354 =+ c=1
@@ -404,7 +404,7 @@ A `set`.
404404
405405#### Source
406406
407−```hoon
407+```reference
408408 +- gas
409409 ~/ %gas
410410 |= b=(list _?>(?=(^ a) n.a))
@@ -448,7 +448,7 @@ A flag.
448448
449449#### Source
450450
451−```hoon
451+```reference
452452 +- has
453453 ~/ %has
454454 |* b=*
@@ -493,7 +493,7 @@ A `set`.
493493
494494#### Source
495495
496−```hoon
496+```reference
497497 +- int
498498 ~/ %int
499499 |* b=_a
@@ -544,7 +544,7 @@ A `set`.
544544
545545#### Source
546546
547−```hoon
547+```reference
548548 +- put
549549 ~/ %put
550550 |* b=*
@@ -597,7 +597,7 @@ A noun.
597597
598598#### Source
599599
600−```hoon
600+```reference
601601 +- rep :: replace by product
602602 |* b=_|=([* *] +<+)
603603 |-
@@ -636,7 +636,7 @@ A set.
636636
637637#### Source
638638
639−```hoon
639+```reference
640640 +- run
641641 ~/ %run
642642 |* b=gate
@@ -675,7 +675,7 @@ A list.
675675
676676#### Source
677677
678−```hoon
678+```reference
679679 +- tap
680680 ~/ %tap
681681 |= b=(list _?>(?=(^ a) n.a))
@@ -717,7 +717,7 @@ A set.
717717
718718#### Source
719719
720−```hoon
720+```reference
721721 +- uni
722722 ~/ %uni
723723 |* b=_a
@@ -775,7 +775,7 @@ An atom.
775775
776776#### Source
777777
778−```hoon
778+```reference
779779 +- wyt :: size of set
780780 |- ^- @
781781 ?~(a 0 +((add $(a l.a) $(a r.a))))
reference/library/2i.md+24−24
@@ -17,7 +17,7 @@ contained arms inherit its sample map, `a`.
1717
1818#### Source
1919
20−```hoon
20+```reference
2121 ++ by
2222 ~/ %by
2323 =| a=(tree (pair))
@@ -61,7 +61,7 @@ A flag.
6161
6262#### Source
6363
64−```hoon
64+```reference
6565 +- all
6666 ~/ %all
6767 |* b=$-(* ?)
@@ -106,7 +106,7 @@ A flag.
106106
107107#### Source
108108
109−```hoon
109+```reference
110110 +- any
111111 ~/ %any
112112 |* b=$-(* ?)
@@ -146,7 +146,7 @@ A flag.
146146
147147#### Source
148148
149−```hoon
149+```reference
150150 +- apt
151151 =| [l=(unit) r=(unit)]
152152 |- ^- ?
@@ -198,7 +198,7 @@ A cell of two maps.
198198
199199#### Source
200200
201−```hoon
201+```reference
202202 +- bif
203203 ~/ %bif
204204 |* [b=* c=*]
@@ -245,7 +245,7 @@ A map.
245245
246246#### Source
247247
248−```hoon
248+```reference
249249 +- def
250250 |* b=_a
251251 ^- (map _p:node (pair (unit _q:node) (unit _q:node)))
@@ -272,7 +272,7 @@ A cell of maps.
272272
273273#### Source
274274
275−```hoon
275+```reference
276276 +- dep
277277 |* b=_a
278278 ^+ [p=a q=a]
@@ -310,7 +310,7 @@ A map.
310310
311311#### Source
312312
313−```hoon
313+```reference
314314 +- del
315315 ~/ %del
316316 |* b=*
@@ -356,7 +356,7 @@ A unit.
356356
357357#### Source
358358
359−```hoon
359+```reference
360360 +- dig
361361 |= b=*
362362 =+ c=1
@@ -395,7 +395,7 @@ A map.
395395
396396#### Source
397397
398−```hoon
398+```reference
399399 +- gas
400400 ~/ %gas
401401 |* b=(list [p=* q=*])
@@ -435,7 +435,7 @@ A unit.
435435
436436#### Source
437437
438−```hoon
438+```reference
439439 +- get
440440 ~/ %get
441441 |= b=*
@@ -483,7 +483,7 @@ A noun.
483483
484484#### Source
485485
486−```hoon
486+```reference
487487 +- got
488488 |* b=*
489489 (need (get b))
@@ -522,7 +522,7 @@ A flag.
522522
523523#### Source
524524
525−```hoon
525+```reference
526526 +- has
527527 ~/ %has
528528 |* b=*
@@ -561,7 +561,7 @@ A map.
561561
562562#### Source
563563
564−```hoon
564+```reference
565565 +- int
566566 ~/ %int
567567 |* b=_a
@@ -633,7 +633,7 @@ A map.
633633
634634#### Assert and Add
635635
636−```hoon
636+```reference
637637 +- mar
638638 |* [b=_?>(?=(^ a) p.n.a) c=(unit ,_?>(?=(^ a) q.n.a))]
639639 ?~ c
@@ -676,7 +676,7 @@ A map.
676676
677677#### Source
678678
679−```hoon
679+```reference
680680 +- put
681681 ~/ %put
682682 |* [b=* c=*]
@@ -737,7 +737,7 @@ A noun.
737737
738738#### Source
739739
740−```hoon
740+```reference
741741 +- rep
742742 |* b=_|=([* *] +<+)
743743 |-
@@ -772,7 +772,7 @@ A cell of nouns.
772772
773773#### Source
774774
775−```hoon
775+```reference
776776 +- rib
777777 |* [b=* c=gate]
778778 |- ^+ [b a]
@@ -812,7 +812,7 @@ A map.
812812
813813#### Source
814814
815−```hoon
815+```reference
816816 +- run
817817 |* b=gate
818818 |-
@@ -851,7 +851,7 @@ A map.
851851
852852#### Source
853853
854−```hoon
854+```reference
855855 +- rut
856856 |* b=gate
857857 |-
@@ -885,7 +885,7 @@ A list.
885885
886886#### Source
887887
888−```hoon
888+```reference
889889 +- tap
890890 =< $
891891 ~/ %tap
@@ -930,7 +930,7 @@ A map.
930930
931931#### Source
932932
933−```hoon
933+```reference
934934 +- uni
935935 ~/ %uni
936936 |* b=_a
@@ -991,7 +991,7 @@ A noun.
991991
992992#### Source
993993
994−```hoon
994+```reference
995995 +- urn
996996 |* b=$-({* *} *)
997997 |-
@@ -1033,7 +1033,7 @@ An atom.
10331033
10341034#### Source
10351035
1036−```hoon
1036+```reference
10371037 +- wyt
10381038 |- ^- @
10391039 ?~(a 0 +((add $(a l.a) $(a r.a))))
reference/library/2j.mddeleted−272
@@ -1,272 +0,0 @@
1−+++
2−title = "2j: Jar and Jug Logic"
3−weight = 13
4−template = "doc.html"
5−aliases = ["/docs/reference/library/2j"]
6−+++
7−### `++ja`
8−
9−Jar engine
10−
11−```hoon
12− |_ a=(jar)
13−```
14−
15−A container arm for `++jar` operation arms. A `++jar` is a `++map` of
16−`++list`s. The contained arms inherit the sample jar.
17−
18−`a` is a jar.
19−
20−```
21− > ~(. ja (mo (limo a/"ho" b/"he" ~)))
22− <2.dgz [nlr([p={%a %b} q=""]) <414.fvk 101.jzo 1.ypj %164>]>
23−```
24−
25−---
26−### `+-get:ja`
27−
28−Grab value by key
29−
30−```hoon
31− +- get :: gets list by key
32− |* b=*
33− =+ c=(~(get by a) b)
34− ?~(c ~ u.c)
35−```
36−
37−#### Accepts
38−
39−`a` is a `++jar`.
40−
41−`b` is a key of the same type as the keys in `a`.
42−
43−#### Produces
44−
45−A list retrieved from jar `a` using the key `b`.
46−
47−Examples
48−
49−```
50− > =l (mo `(list ,[@t (list ,@)])`[['a' `(list ,@)`[1 2 3 ~]] ['b' `(list ,@)`[4 5 6 ~]] ~])
51− > l
52− [[p='a' q=~[1 2 3]] [p='b' q=~[4 5 6]]}
53−
54− > (~(get ja l) 'a')
55− ~[1 2 3]
56−
57− > (~(get ja l) 'b')
58− ~[4 5 6]
59−
60− > (~(get ja l) 'c')
61− ~
62−```
63−
64−---
65−### `+-add:ja`
66−
67−Prepend to list
68−
69−#### Source
70−
71−```hoon
72− +- add :: adds key-list pair
73− |* [b=* c=*]
74− =+ d=(get b)
75− (~(put by a) b [c d])
76−```
77−
78−#### Accepts
79−
80−`a` is a jar.
81−
82−`b` is a key of the same type as the keys in `a`.
83−
84−`c` is a value of the same type as the values in `a`.
85−
86−#### Examples
87−
88−```
89− > =l (mo `(list ,[@t (list ,@)])`[['a' `(list ,@)`[1 2 3 ~]] ['b' `(list ,@)`[4 5 6 ~]] ~])
90− > l
91− {[p='a' q=~[1 2 3]] [p='b' q=~[4 5 6]]}
92−
93− > (~(add ja l) 'b' 7)
94− {[p='a' q=~[1 2 3]] [p='b' q=~[7 4 5 6]]}
95−
96− > (~(add ja l) 'a' 100)
97− {[p='a' q=~[100 1 2 3]] [p='b' q=~[4 5 6]]}
98−
99− > (~(add ja l) 'c' 7)
100− {[p='a' q=~[1 2 3]] [p='c' q=~[7]] [p='b' q=~[4 5 6]]}
101−
102− > (~(add ja l) 'c' `(list ,@)`[7 8 9 ~])
103− ! type-fail
104− ! exit
105−```
106−
107−**
108−### `++ju`
109−
110−Jug operations
111−
112−```hoon
113− ++ ju :: jug engine
114− |/ a=(jug)
115−```
116−
117−Container arm for jug operation arms. A `++jug` is a `++map` of
118−`++sets`. The contained arms inherit its sample jug, `a`.
119−
120−`a` is a jug.
121−
122−```
123− > ~(. ju (mo (limo a=(sa "ho") b=(sa "he") ~)))
124− <2.dgz [nlr([p={%a %b} q={nlr(^$1{@tD $1}) nlr(^$3{@tD $3})}]) <414.fvk 101.jzo 1.ypj %164>]>
125−```
126−
127−### `+-del:ju`
128−
129−Remove
130−
131−
132−#### Source
133−
134−```hoon
135− +- del :: del key-set pair
136− |* [b=* c=*]
137− ^+ a
138− =+ d=(get b)
139− =+ e=(~(del in d) c)
140− ?~ e
141− (~(del by a) b)
142− (~(put by a) b e)
143− ::
144−```
145−
146−Produces jug `a` with value `c` removed from set located at key `b`.
147−
148−`a` is a jug.
149−
150−`b` is a key of the same type as the keys in `a`.
151−
152−`c` is the value of the same type of the keys in `a` that is to be
153−removed.
154−
155−```
156− > s
157− [[p='a' q={1 3 2}] [p='b' q={5 4 6}]}
158−
159− > (~(del ju s) 'a' 1)
160− {[p='a' q={3 2}] [p='b' q={5 4 6}]}
161−
162− > (~(del ju s) 'c' 7)
163− {[p='a' q={1 3 2}] [p='b' q={5 4 6}]}
164−```
165−
166−---
167−
168−### `+-get:ju`
169−
170−Retrieve set
171−
172−```hoon
173− +- get :: gets set by key
174− |* b=*
175− =+ c=(~(get by a) b)
176− ?~(c ~ u.c)
177− ::
178−```
179−
180−Produces a set retrieved from jar `a` using key `b`.
181−
182−`a` is a jar.
183−
184−`b` is a key of the same type as the keys in `a`.
185−
186−```
187− > s
188− {[p='a' q={1 3 2}] [p='b' q={5 4 6}]}
189− > (~(get ju s) 'a')
190− {1 3 2}
191− > (~(get ju s) 'b')
192− {5 4 6}
193− > (~(get ju s) 'c')
194− ~
195−```
196−
197−---
198−### `+-has:ju`
199−
200−Check contents
201−
202−```hoon
203− +- has :: existence check
204− |* [b=* c=*]
205− ^- ?
206− (~(has in (get b)) c)
207− ::
208−```
209−
210−Computes whether a value `c` exists within the set located at key `b`
211−with jar `a`. Produces a loobean.
212−
213−`a` is a set.
214−
215−`b` is a key as a noun.
216−
217−`c` is a value as a noun.
218−
219−```
220− > s
221− {[p='a' q={1 3 2}] [p='b' q={5 4 6}]}
222− > (~(has ju s) 'a' 3)
223− %.y
224− > (~(has ju s) 'b' 6)
225− %.y
226− > (~(has ju s) 'a' 7)
227− %.n
228− > (~(has jus s) 'c' 7)
229− ! -find-limb.jus
230− ! find-none
231− ! exit
232− > (~(has ju s) 'c' 7)
233− %.n
234−```
235−---
236−
237−### `+-put:ju`
238−
239−Add key-set pair
240−
241−```hoon
242− +- put
243− |* {b=* c=*}
244− ^+ a
245− =+ d=(get b)
246− (~(put by a) b (~(put in d) c))
247−```
248−
249−Produces jar `a` with `c` added to the set value located at key `b`.
250−
251−`a` is a set.
252−
253−`b` is a key as a noun.
254−
255−`c` is a value.
256−
257−```
258− > s
259− [p='a' q=[1 3 2]] [p='b' q=[5 4 6]]]
260−
261− > (~(put ju s) 'a' 7)
262− {[p='a' q={7 1 3 2}] [p='b' q={5 4 6}]}
263−
264− > (~(put ju s) 'a' 1)
265− {[p='a' q={1 3 2}] [p='b' q={5 4 6}]}
266−
267− > (~(put ju s) 'c' 7)
268− {[p='a' q={1 3 2}] [p='c' q={7}] [p='b' q={5 4 6}]}
269−```
270−
271−
272−---
reference/library/2k.mddeleted−399
@@ -1,399 +0,0 @@
1−+++
2−title = "2k: Queue Logic"
3−weight = 14
4−template = "doc.html"
5−aliases = ["/docs/reference/library/2k"]
6−+++
7−### `++to`
8−
9−
10−Queue operations
11−
12−Container arm for queue operation arms. The contained arms inherit `a`, its
13−sample queue.
14−
15−#### Accepts
16−
17−`a` is a tree.
18−
19−#### Source
20−
21−```hoon
22− ++ to
23− |_ a=(tree)
24−```
25−
26−#### Discussion
27−
28−`tree` is the generic tree-shape mold. Maps, sets, and queues all share that
29−shape, but they put their elements in different places and have different
30−interfaces. `to` is the interface core for `qeu`; it's not generic across all
31−the different containers that use `tree`.
32−
33−---
34−### `+-bal:to`
35−
36−Balance
37−
38−Vertically rebalances queue `a`.
39−
40−#### Accepts
41−
42−`a` is a queue.
43−
44−#### Produces
45−
46−A queue.
47−
48−#### Source
49−
50−```hoon
51− +- bal
52− |- ^+ a
53− ?~ a ~
54− ?. |(?=($~ l.a) (vor n.a n.l.a))
55− $(a [n.l.a l.l.a $(a [n.a r.l.a r.a])])
56− ?. |(?=($~ r.a) (vor n.a n.r.a))
57− $(a [n.r.a $(a [n.a l.a l.r.a]) r.r.a])
58− a
59−```
60−
61−#### Examples
62−
63−```
64− > `(qeu tape)`["a" ~ "b" ~ "c" ~ "d" ~ "e" ~ "f" ~ "g" ~ ~]
65− {"a" "b" "c" "d" "e" "f" "g"}
66−
67− > `*`["a" ~ "b" ~ "c" ~ "d" ~ "e" ~ "f" ~ "g" ~ ~]
68− [[97 0] 0 [98 0] 0 [99 0] 0 [100 0] 0 [101 0] 0 [102 0] 0 [103 0] 0 0]
69−
70− > ~(bal to `(qeu tape)`["a" ~ "b" ~ "c" ~ "d" ~ "e" ~ "f" ~ "g" ~ ~])
71− [n=[i='d' t=""] l={"a" "b" "c"} r={"e" "f" "g"}]
72−
73− > `*`~(bal to `(qeu tape)`["a" ~ "b" ~ "c" ~ "d" ~ "e" ~ "f" ~ "g" ~ ~])
74− [[100 0] [[99 0] [[98 0] [[97 0] 0 0] 0] 0] [101 0] 0 [102 0] 0 [103 0] 0 0]
75−```
76−
77−---
78−### `+-dep:to`
79−
80−Maximum Depth
81−
82−Produces the maximum depth of leaves (`r.a` and `l.a`) in queue `a`.
83−
84−#### Accepts
85−
86−`a` is a queue.
87−
88−#### Produces
89−
90−An atom.
91−
92−#### Source
93−
94−```hoon
95− +- dep
96− |- ^- @
97− ?~ a 0
98− +((max $(a l.a) $(a r.a)))
99−```
100−
101−#### Examples
102−
103−```
104− > =a (~(gas to `(qeu @)`~) `(list @)`[1 2 3 4 5 6 7 ~])
105− > ~(dep to a)
106− 4
107−
108− > =a (~(gas to `(qeu @)`~) `(list @)`[1 2 3 4 ~])
109− > ~(dep to a)
110− 3
111−
112− > =a (~(gas to `(qeu @)`~) `(list @)`[1 2 ~])
113− > ~(dep to a)
114− 2
115−
116− > ~(dep to `(qeu tape)`["a" ~ "b" ~ "c" ~ "d" ~ "e" ~ "f" ~ "g" ~ ~])
117− 7
118−
119− > ~(dep to ~(bal to `(qeu tape)`["a" ~ "b" ~ "c" ~ "d" ~ "e" ~ "f" ~ "g" ~ ~]))
120− 4
121−```
122−
123−---
124−### `+-gas:to`
125−
126−Push list
127−
128−Push all elements of list `b` into the queue `a`.
129−
130−#### Accepts
131−
132−`a` is a queue.
133−
134−`b` is a list.
135−
136−#### Produces
137−
138−A queue.
139−
140−#### Source
141−
142−```hoon
143− +- gas
144− |= b=(list _?>(?=(^ a) n.a))
145− |- ^+ a
146− ?~(b a $(b t.b, a (put i.b)))
147−```
148−
149−
150−#### Examples
151−
152−```
153− > `(qeu)`(~(gas to `(qeu @)`~) [1 2 3 ~])
154− {3 2 1}
155−
156− > =a (~(gas to `(qeu @)`~) [1 2 3 ~])
157− > =b [4 5 6 ~]
158− > `(qeu)`(~(gas to a) b)
159− {6 5 4 3 2 1}
160−```
161−---
162−### `+-get:to`
163−
164−Head-tail pair
165−
166−Produces the head and tail queue of `a`.
167−
168−#### Accepts
169−
170−`a` is a queue.
171−
172−#### Produces
173−
174−A cell of the last element in `a` along with the rest of queue `a`.
175−
176−#### Source
177−
178−```hoon
179− +- get
180− |- ^+ ?>(?=(^ a) [p=n.a q=*(tree _n.a)])
181− ?~ a
182− !!
183− ?~ r.a
184− [n.a l.a]
185− =+ b=$(a r.a)
186− :- p.b
187− ?: |(?=($~ q.b) (vor n.a n.q.b))
188− [n.a l.a q.b]
189− [n.q.b [n.a l.a l.q.b] r.q.b]
190−```
191−
192−#### Examples
193−
194−```
195− > =s (~(gas to *(tree @)) `(list @)`~[1 2 3])
196− > ~(get to s)
197− [n=2 l={3} r={1}]
198−
199− > ~(get to ~)
200− ! exit
201−```
202−
203−---
204−### `+-nap:to`
205−
206−Remove head
207−
208−Removes the head of queue `a`, producing the resulting queue.
209−
210−#### Accepts
211−
212−`a` is a queue.
213−
214−#### Produces
215−
216−A queue.
217−
218−#### Source
219−
220−```hoon
221− +- nap
222− ?> ?=(^ a)
223− ?~ l.a r.a
224− =+ b=get(a l.a)
225− bal(a ^+(a [p.b q.b r.a]))
226−```
227−
228−#### Examples
229−
230−```
231− > =a (~(gas to `(qeu @)`~) `(list @)`[1 2 3 4 5 6 ~])
232− > -.a
233− n=6
234−
235− > =b ~(nap to a)
236− > -.b
237− n=2
238−
239− > a
240− [n=6 l={} r={5 4 3 2 1}]
241−
242− > b
243− [n=2 l=[n=4 l={5} r={3}] r=[n=1 l={} r={}]]
244−
245− > `(qeu)`b
246− {5 4 3 2 1}
247−
248− > `(qeu)`a
249− {6 5 4 3 2 1}
250−```
251−
252−---
253−### `+-nip:to`
254−
255−Removes the root of queue `a`, producing the resulting queue.
256−
257−#### Accepts
258−
259−`a` is a queue.
260−
261−#### Produces
262−
263−A queue.
264−
265−#### Source
266−
267−```hoon
268− +- nip
269− |- ^+ a
270− ?~ a ~
271− ?~ l.a r.a
272− ?~ r.a l.a
273− ?: (vor n.l.a n.r.a)
274− [n.l.a l.l.a $(l.a r.l.a)]
275− [n.r.a $(r.a l.r.a) r.r.a]
276−```
277−
278−#### Examples
279−
280−```
281− > =a (~(gas to `(qeu @)`~) `(list @)`[1 2 3 4 5 6 ~])
282− > a
283− [n=6 l={} r={5 4 3 2 1}]
284−
285− > ~(nip to a)
286− [n=2 l=[n=4 l={5} r={3}] r=[n=1 l={} r={}]]
287−```
288−
289−---
290−### `+-put:to`
291−
292−Insert
293−
294−Accept any noun `b` and adds to queue `a` as the head, producing the
295−resulting queue.
296−
297−#### Accepts
298−
299−`a` is a queue.
300−
301−`b` is any noun.
302−
303−#### Produces
304−
305−A queue.
306−
307−#### Source
308−
309−```hoon
310− +- put
311− |* b=*
312− |- ^+ a
313− ?~ a
314− [b ~ ~]
315− bal(a a(l $(a l.a)))
316−```
317−
318−#### Examples
319−
320−```
321− > =a (~(gas to `(qeu @)`~) `(list @)`[3 1 2 4 5 6 ~])
322− > `(qeu)`(~(put to a) 7)
323− {7 6 5 4 2 1 3}
324−```
325−
326−---
327−### `+-tap:to`
328−
329−Queue to list
330−
331−Produces queue `a` as a list from front to back.
332−
333−#### Accepts
334−
335−`a` is a queue.
336−
337−#### Produces
338−
339−A list.
340−
341−#### Source
342−
343−```hoon
344− +- tap
345− =| b=(list _?>(?=(^ a) n.a))
346− |- ^+ b
347− =+ 0 :: hack for jet match
348− ?~ a
349− b
350− $(a r.a, b [n.a $(a l.a)])
351−```
352−
353−#### Examples
354−
355−```
356− > =a (~(gas to `(qeu @)`~) [3 1 2 4 5 6 ~])
357− > `*`a
358− [6 0 2 [4 [5 0 0] 0] 1 0 3 0 0]
359− > ~(tap to a)
360− ~[3 1 2 4 5 6]
361−```
362−
363−---
364−### `+-top:to`
365−
366−Produce head
367−
368−Produces the head of queue `a` as a `unit`.
369−
370−#### Accepts
371−
372−`a` is a queue.
373−
374−#### Produces
375−
376−A unit.
377−
378−#### Source
379−
380−```hoon
381− +- top
382− |- ^- (unit _?>(?=(^ a) n.a))
383− ?~ a ~
384− ?~(r.a [~ n.a] $(a r.a))
385−```
386−
387−#### Examples
388−
389−```
390− > =a (~(gas to `(qeu @)`~) `(list @)`[1 2 3 4 5 6 ~])
391− > ~(top to a)
392− [~ u=1]
393−```
394−
395−#### Discussion
396−
397−An empty queue has no head.
398−
399−---
reference/library/2l.mddeleted−111
@@ -1,111 +0,0 @@
1−+++
2−title = "2l: Container from Container"
3−weight = 15
4−template = "doc.html"
5−aliases = ["/docs/reference/library/2l"]
6−+++
7−### `++malt`
8−
9−Map from list
10−
11−Produces a map from a list `a`.
12−
13−#### Accepts
14−
15−`a` is a list.
16−
17−#### Produces
18−
19−A map.
20−
21−#### Source
22−
23−```hoon
24−:- :~ navhome/'/docs/'
25− sort/'14'
26− title/'2k: Jar and Jug Logic'
27− ==
28−
29−;>
30−```
31−
32−#### Examples
33−
34−```
35− > (malt [['ok' 'no'] ['a' 'b'] ['x' 'y'] ~])
36− [n=[p='x' q='y'] l={[p='a' q='b'] [p='ok' q='no']} r={}]
37−
38− > (malt ~[[1 2 3] [4 5 6] [7 8 9]])
39− [n=[p=1 q=[2 3]] l={[p=4 q=[5 6]] [p=7 q=[8 9]]} r={}]
40−```
41−
42−---
43−### `++molt`
44−
45−Map from pair list
46−
47−Produces a map from a list of pairs `a`.
48−
49−#### Accepts
50−
51−`a` is a list of pairs.
52−
53−#### Produces
54−
55−A map.
56−
57−#### Source
58−
59−```hoon
60− ++ molt
61− |* a=(list (pair))
62− (~(gas by `(tree [p=_p.i.-.a q=_q.i.-.a})`~) a)
63−```
64−
65−#### Examples
66−
67−```
68− > =a `(list (pair))`[[1 2] [4 3] [11 0] ~]
69− > a
70− > ~[[p=1 q=2] [p=4 q=3] [p=11 q=0]]
71−
72− > (molt a)
73− [n=[p=11 q=0] l={[p=4 q=3] [p=1 q=2]} r={}]
74−```
75−
76−#### Discussion
77−
78−Only used internally as a helper to `malt`.
79−
80−---
81−### `++silt`
82−
83−Set from list
84−
85−Produces a set from a list `a`.
86−
87−#### Accepts
88−
89−`a` is a list.
90−
91−#### Produces
92−
93−A set.
94−
95−#### Source
96−
97−```hoon
98− ++ silt
99− |* a=(list)
100− =+ b=*(tree _?>(?=(^ a) i.a))
101− (~(gas in b) a)
102−```
103−
104−#### Examples
105−
106−```
107− > (silt `(list @t)`['c' 'hoon' 'javascript' 'python' ~])
108− [n='javascript' l={} r={'python' 'hoon' 'c'}]
109−```
110−
111−---
reference/library/2m.mddeleted−308
@@ -1,308 +0,0 @@
1−+++
2−title = "2m: Container from Noun"
3−weight = 16
4−template = "doc.html"
5−aliases = ["/docs/reference/library/2m"]
6−+++
7−### `++ly`
8−
9−List from raw noun
10−
11−Takes a null-terminated noun and produces a `list`.
12−
13−#### Accepts
14−
15−`a` is a null-terminated noun.
16−
17−#### Produces
18−
19−A `list`.
20−
21−#### Source
22−
23−```hoon
24− ++ ly
25− le:nl
26−```
27−
28−#### Examples
29−
30−```
31− > (ly [1 2 3 ~])
32− ~[1 2 3]
33−
34− > (ly "abc")
35− ~['a' 'b' 'c']
36−```
37−
38−#### Discussion
39−
40−`ly` is an alias for `le:nl`.
41−
42−---
43−### `++my`
44−
45−Map from raw noun
46−
47−Takes a null-terminated noun and produces a `map.`
48−
49−#### Accepts
50−
51−`a` is a noun composed of ordered pairs and terminated with `~`.
52−
53−#### Produces
54−
55−A `map`.
56−
57−#### Source
58−
59−```hoon
60− ++ my
61− my:nl
62−```
63−
64−#### Examples
65−
66−```
67− > (my [['a' 1] ['b' 2] ~])
68− [n=[p='b' q=2] l={[p='a' q=1]} r={}]
69−```
70−
71−#### Discussion
72−
73−`my` is an alias for `my:nl`.
74−
75−---
76−### `++sy`
77−
78−Set from raw noun
79−
80−Takes a null-terminated noun and produces a `set`.
81−
82−#### Accepts
83−
84−`a` is a null-terminated noun.
85−
86−#### Produces
87−
88−A `set`.
89−
90−#### Source
91−
92−```hoon
93− ++ sy
94− si:nl
95−```
96−
97−#### Examples
98−
99−```
100− > (sy [1 2 3 ~])
101− [n=2 l={1 3} r={}]
102−
103− > (sy (ly [1 2 3 ~]))
104− [n=2 l={1 3} r={}]
105−
106− > (sy "abc")
107− [n='b' l={'a' 'c'} r={}]
108−```
109−
110−#### Discussion
111−
112−`sy` is an alias for `si:nl`.
113−
114−---
115−### `++nl`
116−
117−Noun-to-container operations
118−
119−Core whose arms contain functions that create various typed nouns from raw
120−nouns.
121−
122−#### Source
123−
124−```hoon
125− ++ nl
126− |%
127−```
128−
129−---
130−### `++le:nl`
131−
132−Construct list
133−
134−Takes a null-terminated noun and produces a `list`.
135−
136−#### Accepts
137−
138−`a` is a null-terminated noun.
139−
140−#### Produces
141−
142−A list.
143−
144−#### Source
145−
146−```hoon
147− ++ le
148− |* a=(list)
149− ^+ =< $
150− |% +- $ ?:(*? ~ [i=(snag 0 a) t=$])
151− --
152− a
153−```
154−
155−#### Examples
156−
157−```
158− > (le:nl [1 2 3 ~])
159− ~[1 2 3]
160−
161− > (le:nl "abc")
162− ~['a' 'b' 'c']
163−```
164−
165−---
166−### `++my:nl`
167−
168−Construct map
169−
170−Takes a null-terminated noun and produces a `map` of the same type of the `p`
171−and `q` passed in.
172−
173−#### Accepts
174−
175−`a` is a noun composed of ordered pairs and terminated with `~`.
176−
177−#### Produces
178−
179−A map.
180−
181−#### Source
182−
183−```hoon
184− ++ my
185− |* a=(list (pair))
186− => .(a ^+((le a) a))
187− (~(gas by `(map _p.i.-.a _q.i.-.a)`~) a)
188−```
189−
190−#### Examples
191−
192−```
193− > (my:nl [['a' 1] ['b' 2] ~])
194− [n=[p='b' q=2] l={[p='a' q=1]} r={}]
195−```
196−
197−---
198−### `++si:nl`
199−
200−Construct set
201−
202−Takes a null-terminated noun and produces a `set`.
203−
204−#### Accepts
205−
206−`a` is a null-terminated noun.
207−
208−#### Produces
209−
210−A set.
211−
212−#### Source
213−
214−```hoon
215− ++ si
216− |* a=(list)
217− => .(a ^+((le a) a))
218− (~(gas in `(set _i.-.a)`~) a)
219−```
220−
221−#### Examples
222−
223−```
224− > (si:nl `(list [@t *])`[['a' 1] ['b' [2 3]] ~])
225− [n=['b' [2 3]] l={['a' 1]} r={}]
226−```
227−
228−---
229−### `++snag:nl`
230−
231−Index
232−
233−Produces the element at the index `a` of null-terminated noun `b` and failing if
234−the noun is null. Lists are 0-indexed.
235−
236−#### Accepts
237−
238−`a` is a noun.
239−
240−`b` is a null-terminated noun.
241−
242−#### Produces
243−
244−A noun.
245−
246−#### Sources
247−
248−```hoon
249− ++ snag
250− |* [a=@ b=(list)]
251− ?~ b
252− ~_ leaf+"snag-fail"
253− !!
254− ?: =(0 a) i.b
255− $(b t.b, a (dec a))
256−```
257−
258−#### Examples
259−
260−```
261− > =b [[2 3] [1 4] ~]
262− > (snag:nl 0 b)
263− [2 3]
264−
265− > (snag:nl 2 b)
266− ! snag-fail
267− ! exit
268−```
269−
270−---
271−### `++weld:nl`
272−
273−Concatenate
274−
275−Produces a list that is the concatenation of null-terminated nouns `a` and `b`.
276−
277−#### Accepts
278−
279−`a` is a null-terminated noun.
280−
281−`b` is a null-terminated noun.
282−
283−#### Produces
284−
285−A list.
286−
287−#### Source
288−
289−```hoon
290− ++ weld
291− |* [a=(list) b=(list)]
292− => .(a ^+((le a) a), b ^+((le b) b))
293− =+ 42
294− |-
295− ?~ a b
296− [i=i.a t=$(a t.a)]
297−```
298−
299−#### Examples
300−
301−```
302− > =b [[2 3] [1 4] ~]
303−
304− > (weld:nl b [8 9 ~])
305− [i=[2 3] t=[i=[1 4] t=~[8 9]]]
306−```
307−
308−---
reference/library/2n.mddeleted−427
@@ -1,427 +0,0 @@
1−+++
2−title = "2n: Functional Hacks"
3−weight = 17
4−template = "doc.html"
5−aliases = ["/docs/reference/library/2n"]
6−+++
7−### `++cork`
8−
9−Compose forward
10−
11−Build `f` such that `(f x) .= (b (a x))`.
12−
13−#### Accepts
14−
15−`a` is a noun.
16−
17−`b` is a gate.
18−
19−#### Source
20−
21−```hoon
22− ++ cork |*([a=_|=(* **) b=gate] (corl b a))
23−```
24−
25−#### Examples
26−
27−```
28− > (:(cork dec dec dec) 20)
29− 17
30−
31− > =mal (mo (limo a+15 b+23 ~))
32− > ((cork ~(got by mal) dec) %a)
33− 14
34−
35− > ((cork ~(got by mal) dec) %b)
36− 22
37−```
38−
39−---
40−### `++corl`
41−
42−Compose backward
43−
44−Build `f` such that
45−
46−#### Accepts
47−
48−`a` is a gate.
49−
50−`b` is a noun.
51−
52−#### Source
53−
54−```hoon
55− ++ corl
56− |* [a=gate b=_|=(* **)]
57− =< +:|.((a (b))) :: span check
58− |* c=_+<.b
59− (a (b c))
60−```
61−
62−#### Examples
63−
64−```
65− > ((corl (lift bex) (slat %ud)) '2')
66− [~ 4]
67−```
68−
69−---
70−### `++curr`
71−
72−Right curry
73−
74−Right-curry a gate, binding the tail of its sample
75−
76−#### Accepts
77−
78−`a` is a gate.
79−
80−`c` is a noun.
81−
82−#### Produces
83−
84−A gate.
85−
86−#### Source
87−
88−```hoon
89− ++ curr
90− |* [a=_|=(^ **) c=*}
91− |* b=_+<+.a
92− (a b c)
93−```
94−
95−#### Examples
96−
97−```
98− > =tep (curr scan sym)
99− > `@t`(tep "asd")
100− 'asd'
101−
102− > `@t`(tep "lek-om")
103− 'lek-om'
104−```
105−
106−---
107−### `++cury`
108−
109−Curry left
110−
111−Curry a gate, binding the head of its sample
112−
113−#### Accepts
114−
115−`a` is a gate.
116−
117−`b` is a noun.
118−
119−#### Produces
120−
121−A gate.
122−
123−#### Source
124−
125−```hoon
126− ++ cury
127− |* [a=_|=(^ **) b=*}
128− |* c=_+<+.a
129− (a b c)
130−```
131−
132−#### Examples
133−
134−```
135− > =mol (cury add 2)
136− > (mol 4)
137− 6
138−
139− > (mol 7)
140− 9
141−```
142−
143−---
144−### `++hard`
145−
146−Force remold
147−
148−Demands that a specific type be produced, crashing the program if it is
149−not.
150−
151−#### Source
152−
153−```hoon
154− ++ hard
155− |* han=gate
156− |= fud=* ^- han
157− ~_ leaf+"hard"
158− =+ gol=(han fud)
159− ?>(=(gol fud) gol)
160−```
161−
162−#### Examples
163−
164−```
165− > ((hard (list)) (limo [1 2 3 ~]))
166− ~[1 2 3]
167− > ((hard @) (add 2 2))
168− 4
169− > ((hard @t) (crip "Tape to cord, bro!"))
170− 'Tape to cord, bro'
171− > ((hard tape) (crip "...Tape to cord, bro?..."))
172− ! hard
173− ! exit
174−```
175−
176−
177−---
178−### `++soft`
179−
180−Maybe remold
181−
182−Politely requests a specific type to be produced, producing null if it
183−is not.
184−
185−#### Source
186−
187−```hoon
188− ++ soft
189− |* han=gate
190− |= fud=* ^- (unit han)
191− =+ gol=(han fud)
192− ?.(=(gol fud) ~ [~ gol])
193−```
194−
195−#### Examples
196−
197−```
198− > ((soft %4) (add 2 2))
199− [~ %4]
200−
201− > ((soft @) (add 2 2))
202− [~ 4]
203−
204− > ((soft %5) (add 2 2))
205− ~
206−
207− > ((soft @t) (crip "Tape to cord, Woohoo!"))
208− [~ 'Tape to cord, Woohoo!']
209−
210− > ((soft @t) (trip 'Cmon man... Tape to cord? Please?!'))
211− ~
212−```
213−
214−
215−---
216−### `++head`
217−
218−Get head
219−
220−Produces the head of a cell.
221−
222−#### Accepts
223−
224−A cell.
225−
226−#### Produces
227−
228−An atom.
229−
230−#### Source
231−
232−```hoon
233− ++ head |*(^ ,:+<-)
234−```
235−
236−#### Examples
237−
238−```
239− > (head [1 2])
240− 1
241−
242− > (head [[1 1] 2])
243− [1 1]
244−
245− > (head "hello")
246− 'h'
247−```
248−
249−---
250−### `++same`
251−
252−Identity
253−
254−Produces the same value that it was given.
255−
256−#### Accepts
257−
258−A noun.
259−
260−#### Produces
261−
262−A noun.
263−
264−#### Source
265−
266−```hoon
267− ++ same |*(* +<)
268−```
269−
270−#### Examples
271−
272−```
273− > (same [1 2])
274− [1 2]
275−
276− > (same [[1 1] 2])
277− [[1 1] 2]
278−
279− > (same "hello")
280− "hello"
281−```
282−
283−---
284−### `++slog`
285−
286−Deify printf
287−
288−Produces a stack trace if the stack trace isn't null, then produces the other
289−input.
290−
291−#### Accepts
292−
293−A `tang`.
294−
295−#### Produces
296−
297−A `tang`.
298−
299−#### Source
300−
301−```hoon
302− ++ slog
303− =| pri=@
304− |= a=tang ^+ same
305− ?~(a same ~>(%slog.[pri i.a] $(a t.a)))
306−```
307−
308−#### Examples
309−
310−```
311− > =+ result=((slog [%leaf "error-message"]~) [12 13]) [%product result]
312− [%product 12 13]
313−```
314−
315−#### Discussion
316−
317−`slog` is intended to be put in the middle of a bunch of chained function
318−calls that string a piece of data through them, so that an error message will be
319−printed if there's one to print.
320−
321−---
322−### `++mean`
323−
324−Crash and printf
325−
326−Ends the program and produces a `tang` tracing error message.
327−
328−#### Accepts
329−
330−`a` is a tang.
331−
332−#### Produces
333−
334−A crash.
335−
336−#### Source
337−
338−```hoon
339− ++ mean
340− |= a=tang
341− ^+ !!
342− ?~ a !!
343− ~_(i.a $(a t.a))
344−```
345−
346−#### Examples
347−
348−```
349− > ~>(%mean.[%leaf "fuse-loop"] !!)
350− ####
351− !! crash
352−```
353−
354−---
355−### `++tail`
356−
357−Get tail
358−
359−Produces the tail of a cell.
360−
361−#### Accepts
362−
363−A cell.
364−
365−#### Produces
366−
367−A noun.
368−
369−#### Source
370−
371−```hoon
372− ++ tail |*(^ ,:+<+)
373−```
374−
375−#### Examples
376−
377−```
378− > (tail [1 2])
379− 2
380−
381− > (tail [[1 1] 2])
382− 2
383−
384− > (tail "hello")
385− "ello"
386−```
387−
388−---
389−### `++test`
390−
391−Test for equality
392−
393−Checks if `a` and `b` are equal, producing a flag.
394−
395−#### Accepts
396−
397−`a` is a noun.
398−
399−`b` is a noun.
400−
401−#### Produces
402−
403−A flag.
404−
405−#### Source
406−
407−```hoon
408− ++ test |=(^ =(+<- +<+))
409−```
410−
411−#### Examples
412−
413−```
414− > (test 1 1)
415− %.y
416−
417− > (test [2 0] 2)
418− %.n
419−
420− > (test "hello" 'hello')
421− %.n
422−
423− > (test "hello" ['h' 'e' 'l' 'l' 'o' ~])
424− %.y
425−```
426−
427−---
reference/library/2o.md+5−5
@@ -10,7 +10,7 @@ Mold generator. A `jar` is a `map` of `list`.
1010
1111#### Source
1212
13−```hoon
13+```reference
1414 ++ jar |*([a=mold b=mold] (map a (list b)))
1515```
1616
@@ -47,7 +47,7 @@ Mold generator. A `jug` is a `map` of `set`.
4747
4848#### Source
4949
50−```hoon
50+```reference
5151 ++ jug |*([a=mold b=mold] (map a (set b)))
5252```
5353
@@ -91,7 +91,7 @@ key-value pairs.
9191
9292#### Source
9393
94−```hoon
94+```reference
9595 ++ map |* [a=mold b=mold]
9696 %+ cork (tree (pair a b))
9797 |= c=(tree (pair a b)) ^+ c
@@ -123,7 +123,7 @@ items.
123123
124124#### Source
125125
126−```hoon
126+```reference
127127 ++ qeu |*(a=mold (tree a))
128128```
129129
@@ -160,7 +160,7 @@ items.
160160
161161#### Source
162162
163−```hoon
163+```reference
164164 ++ set |* a=mold
165165 %+ cork (tree a)
166166 |= b=(tree a) ^+ b
reference/library/2p.mddeleted−242
@@ -1,242 +0,0 @@
1−+++
2−title = "2p: Serialization"
3−weight = 19
4−template = "doc.html"
5−aliases = ["/docs/reference/library/2p"]
6−+++
7−### `++cue`
8−
9−Unpack atom to noun
10−
11−Produces a noun unpacked from atom `a`. The inverse of `jam`.
12−
13−#### Accepts
14−
15−An Atom.
16−
17−#### Produces
18−
19−A noun.
20−
21−#### Source
22−
23−```hoon
24− ++ cue
25− ~/ %cue
26− |= a=@
27− ^- *
28− =+ b=0
29− =+ m=`(map @ *)`~
30− =< q
31− |- ^- [p=@ q=* r=(map @ *)]
32− ?: =(0 (cut 0 [b 1] a))
33− =+ c=(rub +(b) a)
34− [+(p.c) q.c (~(put by m) b q.c)]
35− =+ c=(add 2 b)
36− ?: =(0 (cut 0 [+(b) 1] a))
37− =+ u=$(b c)
38− =+ v=$(b (add p.u c), m r.u)
39− =+ w=[q.u q.v]
40− [(add 2 (add p.u p.v)) w (~(put by r.v) b w)]
41− =+ d=(rub c a)
42− [(add 2 p.d) (need (~(get by m) q.d)) m]
43−```
44−
45−#### Examples
46−
47−```
48− > (cue 12)
49− 1
50−
51− > (cue 817)
52− [1 1]
53−
54− > (cue 4.657)
55− [1 2]
56−
57− > (cue 39.689)
58− [0 19]
59−```
60−
61−---
62−### `++jam`
63−
64−Pack noun to atom
65−
66−Produces an atom packed from noun `a`. The inverse of `cue`.
67−
68−#### Accepts
69−
70−`a` is a noun.
71−
72−#### Produces
73−
74−An atom.
75−
76−#### Source
77−
78−```hoon
79− ++ jam
80− ~/ %jam
81− |= a=*
82− ^- @
83− =+ b=0
84− =+ m=`(map * @)`~
85− =< q
86− |- ^- [p=@ q=@ r=(map * @)]
87− =+ c=(~(get by m) a)
88− ?~ c
89− => .(m (~(put by m) a b))
90− ?: ?=(@ a)
91− =+ d=(mat a)
92− [(add 1 p.d) (lsh 0 1 q.d) m]
93− => .(b (add 2 b))
94− =+ d=$(a -.a)
95− =+ e=$(a +.a, b (add b p.d), m r.d)
96− [(add 2 (add p.d p.e)) (mix 1 (lsh 0 2 (cat 0 q.d q.e))) r.e]
97− ?: ?&(?=(@ a) (lte (met 0 a) (met 0 u.c)))
98− =+ d=(mat a)
99− [(add 1 p.d) (lsh 0 1 q.d) m]
100− =+ d=(mat u.c)
101− [(add 2 p.d) (mix 3 (lsh 0 2 q.d)) m]
102−```
103−
104−#### Examples
105−
106−```
107− > (jam 1)
108− 12
109−
110− > (jam [1 1])
111− 817
112−
113− > (jam [1 2])
114− 4.657
115−
116− > (jam [~ u=19])
117− 39.689
118−```
119−
120−#### Discussion
121−
122−`mat` is only used internally as a helper to `jam`.
123−
124−---
125−### `++mat`
126−
127−Length-encode
128−
129−Produces a cell whose tail `q` is atom `a` with a bit representation of
130−its length prepended to it (as the least significant bits). The head `p`
131−is the length of `q` in bits.
132−
133−#### Accepts
134−
135−`a` is an atom.
136−
137−#### Produces
138−
139−A cell of two atoms.
140−
141−#### Source
142−
143−```hoon
144− ++ mat
145− ~/ %mat
146− |= a=@
147− ^- [p=@ q=@]
148− ?: =(0 a)
149− [1 1]
150− =+ b=(met 0 a)
151− =+ c=(met 0 b)
152− :- (add (add c c) b)
153− (cat 0 (bex c) (mix (end 0 (dec c) b) (lsh 0 (dec c) a)))
154−```
155−
156−#### Examples
157−
158−```
159− > (mat 0xaaa)
160− [p=20 q=699.024]
161−
162− > (met 0 q:(mat 0xaaa))
163− 20
164−
165− > `@ub`q:(mat 0xaaa)
166− 0b1010.1010.1010.1001.0000
167−
168− > =a =-(~&(- -) `@ub`0xaaa)
169− 0b1010.1010.1010
170−
171− > =b =-(~&(- -) `@ub`(xeb a))
172− 0b1100
173−
174− > =b =-(~&(- -) `@ub`(met 0 a))
175− 0b1100
176−
177− > =c =-(~&(- -) (xeb b))
178− 4
179−
180− > [`@ub`a `@ub`(end 0 (dec c) b) `@ub`(bex c)]
181− [0b1010.1010.1010 0b100 0b1.0000]
182−```
183−
184−
185−---
186−### `++rub`
187−
188−Length-decode
189−
190−The inverse of `mat`. Accepts a cell of index `a` and a bitstring `b`
191−and produces the cell whose tail `q` is the decoded atom at index `a`
192−and whose head is the length of the encoded atom `q`, by which the
193−offset `a` is advanced.
194−
195−#### Accepts
196−
197−`a` is an atom.
198−
199−`b` is a bitstring as an atom.
200−
201−#### Produces
202−
203−A cell of two atoms.
204−
205−#### Source
206−
207−```hoon
208− ++ rub
209− ~/ %rub
210− |= [a=@ b=@]
211− ^- [p=@ q=@]
212− =+ ^= c
213− =+ [c=0 m=(met 0 b)]
214− |- ?< (gth c m)
215− ?. =(0 (cut 0 [(add a c) 1] b))
216− c
217− $(c +(c))
218− ?: =(0 c)
219− [1 0]
220− =+ d=(add a +(c))
221− =+ e=(add (bex (dec c)) (cut 0 [d (dec c)] b))
222− [(add (add c c) e) (cut 0 [(add d (dec c)) e] b)]
223−```
224−
225−#### Examples
226−
227−```
228− > `@ub`(jam 0xaaa)
229− 0b1.0101.0101.0101.0010.0000
230−
231− > (rub 1 0b1.0101.0101.0101.0010.0000)
232− [p=20 q=2.730]
233−
234− > `@ux`q:(rub 1 0b1.0101.0101.0101.0010.0000)
235− 0xaaa
236−```
237−
238−#### Discussion
239−
240−`rub` is only used internally as a helper to `cue`.
241−
242−---
reference/library/2q.md+11−11
@@ -14,7 +14,7 @@ consume `tape`s, which are lists of `char`.
1414
1515#### Source
1616
17−```hoon
17+```reference
1818 ++ char @tD
1919```
2020
@@ -38,7 +38,7 @@ atom of UTF-8 text.
3838
3939#### Source
4040
41−```hoon
41+```reference
4242 ++ cord @t
4343```
4444
@@ -81,7 +81,7 @@ which is a day atom and a time.
8181
8282#### Source
8383
84−```hoon
84+```reference
8585 ++ date [[a=? y=@ud] m=@ud t=tarp]
8686```
8787
@@ -112,7 +112,7 @@ An atom type that only permits ASCII characters.
112112
113113#### Source
114114
115−```hoon
115+```reference
116116
117117 ++ knot @ta
118118```
@@ -137,7 +137,7 @@ traces.
137137
138138#### Source
139139
140−```hoon
140+```reference
141141 ++ tang (list tank)
142142```
143143
@@ -173,7 +173,7 @@ without back-steps at new lines.
173173
174174#### Source
175175
176−```hoon
176+```reference
177177 ++ tank $% [$leaf p=tape]
178178 $: $palm
179179 p=[p=tape q=tape r=tape s=tape]
@@ -227,7 +227,7 @@ One of Hoon's two string types, the other being `++cord`. A tape is a list of
227227
228228#### Source
229229
230−```hoon
230+```reference
231231 ++ tape (list @tD)
232232```
233233
@@ -260,7 +260,7 @@ for precision.
260260
261261#### Source
262262
263−```hoon
263+```reference
264264 ++ tarp [d=@ud h=@ud m=@ud s=@ud f=(list @ux)]
265265```
266266
@@ -295,7 +295,7 @@ special syntax, `$`.
295295
296296#### Source
297297
298−```hoon
298+```reference
299299 ++ term @tas
300300```
301301
@@ -326,7 +326,7 @@ A list of `cord`s. A `wain` is used instead of a single `cord` with `\n`.
326326
327327#### Source
328328
329−```hoon
329+```reference
330330 ++ wain (list cord)
331331```
332332
@@ -349,7 +349,7 @@ A list of `tape`s. `wall` is used instead of a single `tape` with `\n`.
349349
350350#### Source
351351
352−```hoon
352+```reference
353353 ++ wall (list tape)
354354```
355355#### Examples
reference/library/3a.mddeleted−858
@@ -1,858 +0,0 @@
1−+++
2−title = "3a: Modular and Signed Ints"
3−weight = 21
4−template = "doc.html"
5−aliases = ["/docs/reference/library/3a"]
6−+++
7−### `++egcd`
8−
9−Extended Euclidean algorithm
10−
11−Produces `d`, the
12−[greatest common divisor](https://en.wikipedia.org/wiki/Greatest_common_divisor)
13−of `a` and `b`. Also produces `u` and `v` such that `au + bv = GCD(a, b)`.
14−
15−#### Accepts
16−
17−`a` is an atom.
18−
19−`b` is an atom.
20−
21−#### Produces
22−
23−`d`, the greatest common divisor, is an atom.
24−
25−`u`, the coefficient of `a`, is a signed integer.
26−
27−`v`, the coefficient of `b`, is a signed integer.
28−
29−#### Source
30−
31−```hoon
32− ++ egcd
33− |= [a=@ b=@]
34− =+ si
35− =+ [c=(sun a) d=(sun b)]
36− =+ [u=[c=(sun 1) d=--0] v=[c=--0 d=(sun 1)]]
37− |- ^- [d=@ u=@s v=@s]
38− ?: =(--0 c)
39− [(abs d) d.u d.v]
40− =+ q=(fra d c)
41− %= $
42− c (dif d (pro q c))
43− d c
44− u [(dif d.u (pro q c.u)) c.u]
45− v [(dif d.v (pro q c.v)) c.v]
46− ==
47−```
48−
49−#### Examples
50−
51−```
52− > (egcd 11 2)
53− [d=1 u=--1 v=-5]
54−```
55−
56−---
57−### `++fo`
58−
59−Modulo prime
60−
61−Container core for modular arithmetic functions.
62−
63−#### Source
64−
65−```hoon
66− ++ fo
67− ^?
68− |_ a=@
69−```
70−
71−---
72−### `++dif:fo`
73−
74−Subtraction
75−
76−Produces the difference between atoms `b` and `c`, with `a` as the modular base.
77−
78−#### Accepts
79−
80−`a` is an atom.
81−
82−`b` is an atom.
83−
84−`c` is an atom.
85−
86−#### Produces
87−
88−An atom.
89−
90−#### Source
91−
92−```hoon
93− ++ dif
94− |= [b=@ c=@]
95− (sit (sub (add a b) (sit c)))
96−```
97−
98−#### Examples
99−
100−```
101− > (~(dif fo 6) 1 2)
102− 5
103−
104− > (~(dif fo 21) 11 45)
105− 8
106−```
107−
108−---
109−### `++exp:fo`
110−
111−Exponent
112−
113−Produces the power of `c` raised to the `b`, with `a` as the modular base.
114−
115−#### Accepts
116−
117−`a` is an atom.
118−
119−`b` is an atom.
120−
121−`c` is an atom.
122−
123−#### Produces
124−
125−An atom.
126−
127−#### Source
128−
129−```hoon
130− ++ exp
131− |= [b=@ c=@]
132− ?: =(0 b)
133− 1
134− =+ d=$(b (rsh 0 1 b))
135− =+ e=(pro d d)
136− ?:(=(0 (end 0 1 b)) e (pro c e))
137−```
138−
139−#### Examples
140−
141−```
142− > (~(exp fo 5) 8 2)
143− 1
144−
145− > (~(exp fo 95) 8 2)
146− 66
147−
148− > (~(exp fo 195) 8 2)
149− 61
150−
151− > (~(exp fo 995) 8 2)
152− 256
153−```
154−
155−---
156−### `++fra:fo`
157−
158−Divide
159−
160−Produces the quotient of `b` divided by `c`, with `a` as the modular base.
161−
162−#### Accepts
163−
164−`a` is an atom.
165−
166−`b` is an atom.
167−
168−`c` is an atom.
169−
170−#### Produces
171−
172−An atom.
173−
174−#### Accepts
175−
176−`a` is an atom.
177−
178−`b` is an atom.
179−
180−#### Source
181−
182−```hoon
183− ++ fra
184− |= [b=@ c=@]
185− (pro b (inv c))
186−```
187−
188−#### Examples
189−
190−```
191− > (~(fra fo 2) 8 2)
192− 0
193−
194− > (~(fra fo 3) 8 2)
195− 1
196−
197− > (~(fra fo 4) 8 2)
198− 0
199−
200− > (~(fra fo 5) 8 2)
201− 4
202−```
203−
204−---
205−### `++inv:fo`
206−
207−Inverse
208−
209−Produces an atom by taking the signed modulus of `a` with the coefficient `u`;
210−`u` is produced by taking the `++egcd` of `a` and `b`.
211−
212−#### Accepts
213−
214−`a` is an atom.
215−
216−`b` is an atom.
217−
218−#### Produces
219−
220−An atom.
221−
222−#### Source
223−
224−```hoon
225− ++ inv
226− |= b=@
227− =+ c=(dul:si u:(egcd b a) a)
228− c
229−```
230−
231−#### Examples
232−
233−```
234− > (~(inv fo 11) 2)
235− 6
236−
237− > (~(inv fo 71) 255)
238− 22
239−
240− > (~(inv fo 79) 255)
241− 22
242−
243− > (~(inv fo 78) 255)
244− 67
245−
246− > (~(inv fo 70) 255)
247− 67
248−```
249−
250−---
251−### `++pro:fo`
252−
253−Multiplication
254−
255−Produces the multiplication of `b` and `c` modulo `a`.
256−
257−#### Accepts
258−
259−`a` is an atom.
260−
261−`b` is an atom.
262−
263−`c` is an atom.
264−
265−#### Produces
266−
267−An atom.
268−
269−#### Source
270−
271−```hoon
272− ++ pro
273− |= [b=@ c=@]
274− (sit (mul b c))
275−```
276−
277−#### Examples
278−
279−```
280− > (~(pro fo 3) 11 4)
281− 2
282−
283− > (mod 44 3)
284− 2
285−```
286−
287−---
288−### `++sit:fo`
289−
290−Modulus
291−
292−Produces the remainder of `b` modulo `a`.
293−
294−#### Accepts
295−
296−`a` is an atom.
297−
298−`b` is an atom.
299−
300−#### Produces
301−
302−An atom.
303−
304−#### Source
305−
306−```hoon
307− ++ sit
308− |= b=@
309− (mod b a)
310−```
311−
312−#### Examples
313−
314−```
315− > (~(sit fo 3) 14)
316− 2
317−```
318−
319−---
320−### `++sum:fo`
321−
322−Modular sum
323−
324−Produces the remainder of `(b + c) mod a`.
325−
326−#### Accepts
327−
328−`a` is an atom.
329−
330−`b` is an atom.
331−
332−`c` is an atom.
333−
334−#### Produces
335−
336−An atom.
337−
338−#### Source
339−
340−```hoon
341− ++ sum
342− |= [b=@ c=@]
343− (sit (add b c))
344− --
345−```
346−
347−#### Examples
348−
349−```
350− > (~(sum fo 3) 14 3)
351− 2
352−
353− > (mod 17 3)
354− 2
355−```
356−
357−---
358−### `++si`
359−
360−Signed integer
361−
362−Container core for signed integer functions.
363−
364−#### Source
365−
366−```hoon
367− ++ si
368− ^?
369− |%
370−```
371−
372−#### Discussion
373−
374−The signed-integer type is represented by the `@s` aura. Positive integers are
375−represented with a two prepending `-`s, and negative integers are represented
376−with two; `--1` and `-1`, respectively.
377−
378−Positive signed integers correspond to odd atoms of twice their absolute value,
379−and negative signed integers correspond to atoms of twice their absolute value
380−minus one. For example:
381−
382−```
383− > `@`--4
384− 8
385− > `@s`8
386− --4
387−
388− > `@`-4
389− 7
390− > `@s`7
391− -4
392−```
393−
394−---
395−### `++abs:si`
396−
397−Absolute value
398−
399−Produces the absolute value of signed integer `a`.
400−
401−#### Accepts
402−
403−`a` is a signed integer.
404−
405−#### Produces
406−
407−An atom.
408−
409−### Source
410−
411−```hoon
412− ++ abs |=(a=@s (add (end 0 1 a) (rsh 0 1 a)))
413−```
414−
415−#### Examples
416−
417−```
418− > (abs:si -11)
419− 11
420−
421− > (abs:si --520)
422− 520
423−```
424−
425−---
426−### `++dif:si`
427−
428−Subtraction
429−
430−Produces the difference of `a` minus `b`.
431−
432−#### Accepts
433−
434−`a` is a signed integer.
435−
436−`b` is a signed integer.
437−
438−#### Produces
439−
440−A signed integer.
441−
442−#### Source
443−
444−```hoon
445− ++ dif |= [a=@s b=@s]
446− (sum a (new !(syn b) (abs b)))
447−```
448−
449−#### Examples
450−
451−```
452− > (dif:si --3 -2)
453− --5
454−
455− > (dif:si -3 --2)
456− -5
457−```
458−
459−---
460−### `++dul:si`
461−
462−Modulus
463−
464−Produces the remainder of `b` modulo `a`.
465−
466−#### Examples
467−
468−`a` is a signed integer.
469−
470−`b` is an atom.
471−
472−#### Produces
473−
474−An atom.
475−
476−#### Source
477−
478−```hoon
479− ++ dul |= [a=@s b=@]
480− =+(c=(old a) ?:(-.c (mod +.c b) (sub b +.c)))
481−```
482−
483−#### Examples
484−
485−```
486− > `@s`(dul:si -1 --5)
487− -5
488−
489− > `@`--5
490− 10
491− > `@s`(dul:si -1 10)
492− -5
493−
494− > `@s`(dul:si -11 -61)
495− --55
496−```
497−
498−---
499−### `++fra:si`
500−
501−Divide
502−
503−Produces the quotient of `b` divided by `c`.
504−
505−#### Accepts
506−
507−`a` is a signed integer.
508−
509−`b` is a signed integer.
510−
511−#### Produces
512−
513−A signed atom.
514−
515−#### Source
516−
517−```hoon
518− ++ fra |= [a=@s b=@s]
519− (new =(0 (mix (syn a) (syn b))) (div (abs a) (abs b)))
520−```
521−
522−#### Examples
523−
524−```
525− > (fra:si -1 -1)
526− --1
527−
528− > (fra:si -11 --2)
529− -5
530−
531− > (fra:si -0 -1)
532− --0
533−```
534−
535−---
536−### `++new:si`
537−
538−Atom to @s
539−
540−Produces a signed integer from an atom `b`. The product's sign is determined
541−by the value of flag `a`: `&` will result in a prepending `--`, and `|` will
542−result in a prepending `-`.
543−
544−#### Accepts
545−
546−`a` is a flag.
547−
548−`b` is an atom.
549−
550−#### Produces
551−
552−A signed integer.
553−
554−#### Source
555−
556−```hoon
557− ++ new |= [a=? b=@]
558− `@s`?:(a (mul 2 b) ?:(=(0 b) 0 +((mul 2 (dec b)))))
559−```
560−
561−#### Examples
562−
563−```
564− > (new:si | 2)
565− -2
566−
567− > (new:si & 2)
568− --2
569−
570− > (new:si & -2)
571− --3
572−
573− > (new:si & --2)
574− --4
575−```
576−
577−---
578−### `++old:si`
579−
580−Sign and absolute value
581−
582−Produces a cell composed of a `%.y` or `%.n`, depending on whether `a` is
583−positive or negative, and the absolute value of `a`.
584−
585−#### Accepts
586−
587−`a` is a signed integer.
588−
589−#### Produces
590−
591−A cell composed of a `term` and an atom.
592−
593−#### Source
594−
595−```hoon
596− ++ old |=(a=@s [(syn a) (abs a)])
597−```
598−
599−#### Examples
600−
601−```
602− > (old:si -2)
603− [%.n 2]
604−
605− > (old:si --2)
606− [%.y 2]
607−```
608−
609−---
610−### `++pro:si`
611−
612−Multiplication
613−
614−Produces a signed integer by multiplying `a` and `b`.
615−
616−#### Accepts
617−
618−`a` is an unsigned integer.
619−
620−`b` is an unsigned integer.
621−
622−#### Source
623−
624−```hoon
625− ++ pro |= [a=@s b=@s]
626− (new =(0 (mix (syn a) (syn b))) (mul (abs a) (abs b)))
627−```
628−
629−#### Examples
630−
631−```
632− > (pro:si -3 -3)
633− --9
634−
635− > (pro:si -3 --3)
636− -9
637−```
638−
639−---
640−### `++rem:si`
641−
642−Remainder
643−
644−Produces a signed integer that is the remainder of `a` divided by `b`.
645−
646−#### Accepts
647−
648−`a` is a signed integer.
649−
650−`b` is a signed integer.
651−
652−#### Produces
653−
654−A signed integer.
655−
656−#### Source
657−
658−```hoon
659− ++ rem |=([a=@s b=@s] (dif a (pro b (fra a b))))
660−```
661−
662−#### Examples
663−
664−```
665− > (rem:si -17 -3)
666− -2
667−
668− > (rem:si --17 -3)
669− --2
670−
671− > (rem:si -17 --3)
672− -2
673−
674− > (rem:si --17 --3)
675− --2
676−```
677−
678−
679−---
680−### `++sum:si`
681−
682−Addition
683−
684−Produces an atom by adding `a` and `b`.
685−
686−#### Accepts
687−
688−`a` is a signed integer.
689−
690−`b` is a signed integer.
691−
692−#### Produces
693−
694−A signed integer.
695−
696−#### Source
697−
698−```hoon
699− ++ sum |= [a=@s b=@s]
700− =+ [c=(old a) d=(old b)]
701− ?: -.c
702− ?: -.d
703− (new & (add +.c +.d))
704− ?: (gte +.c +.d)
705− (new & (sub +.c +.d))
706− (new | (sub +.d +.c))
707− ?: -.d
708− ?: (gte +.c +.d)
709− (new | (sub +.c +.d))
710− (new & (sub +.d +.c))
711− (new | (add +.c +.d))
712−```
713−
714−#### Examples
715−
716−```
717− > (sum:si -11 --2)
718− -9
719−
720− > (sum:si --2 --2)
721− --4
722−```
723−
724−---
725−### `++sun:si`
726−
727−@u to @s
728−
729−Multiplies the unsigned integer `a` by two, producing an atom.
730−
731−#### Accepts
732−
733−`a` is an unsigned integer.
734−
735−#### Produces
736−
737−An atom.
738−
739−#### Source
740−
741−```hoon
742− ++ sun |=(a=@u (mul 2 a))
743−```
744−
745−#### Examples
746−
747−```
748− > (sun:si 90)
749− 180
750−
751− > (sun:si --90)
752− 360
753− > `@u`--90
754− 180
755−
756− > (sun:si --89)
757− 356
758− > `@u`--89
759− 178
760−
761− > (sun:si -89)
762− 354
763− > `@u`-89
764− 177
765−```
766−
767−---
768−### `++syn:si`
769−
770−Sign test
771−
772−Tests whether signed atom `a` is positive or negative. `%.y` is produced if `a`
773−is positive, and `%.n` is produced if `a` is negative.
774−
775−#### Accepts
776−
777−`a` is a signed integer.
778−
779−#### Produces
780−
781−An `term`.
782−
783−#### Source
784−
785−```hoon
786− ++ syn |=(a=@s =(0 (end 0 1 a)))
787−```
788−
789−#### Examples
790−
791−```
792− > (syn:si -2)
793− %.n
794−
795− > (syn:si --2)
796− %.y
797−```
798−
799−---
800−### `++cmp:si`
801−
802−Compare
803−
804−Compares `a` and `b` to see which is greater. If `a` is greater than `b`, `--1`
805−is produced. If `b` is greater than `a`, `-1` is produced. If `a` and `b` are
806−equal, `--0` is produced.
807−
808−#### Accepts
809−
810−`a` is a signed integer.
811−
812−`b` is a signed integer.
813−
814−#### Produces
815−
816−A signed integer.
817−
818−#### Source
819−
820−```hoon
821− ++ cmp |= [a=@s b=@s]
822− ^- @s
823− ?: =(a b)
824− --0
825− ?: (syn a)
826− ?: (syn b)
827− ?: (gth a b)
828− --1
829− -1
830− --1
831− ?: (syn b)
832− -1
833− ?: (gth a b)
834− -1
835− --1
836− --
837−```
838−
839−#### Examples
840−
841−```
842− > (cmp:si -2 --1)
843− -1
844−
845− > (cmp:si -2 --1)
846− -1
847−
848− > (cmp:si --2 --1)
849− --1
850−
851− > (cmp:si --2 --2)
852− --0
853−
854− > (cmp:si --2 --5)
855− -1
856−```
857−
858−---
reference/library/3b.mddeleted−5889
@@ -1,5889 +0,0 @@
1−+++
2−title = "3b: Floating Point"
3−weight = 22
4−template = "doc.html"
5−aliases = ["/docs/reference/library/3b"]
6−+++
7−### `++fn`
8−
9−Float
10−
11−A mold for the floating-point arithmetic using the base of two, the formula is
12−`(-1)^s * a * 2^e`.
13−
14−Produces either a float (`$f`), an infinity of other sign (`$i`),
15−or not-a-number (`$n`). `s` refers to sign, the `flag`s `&` or `|`; `e` to
16−exponent, a signed decimal; and `a` to the significand, an unsigned integer.
17−
18−#### Source
19−
20−```hoon
21− ++ fn
22− $% [$f s=? e=@s a=@u]
23− [$i s=?]
24− [$n ~]
25− ==
26−```
27−
28−### Examples
29−
30−```
31− > *fn
32− [%n ~]
33−
34− > (add:fl [%f & --33 2] [%f | --23 2])
35− [%f s=%.y e=-79 a=10.374.452.512.267.829.421.849.019.032.797.184]
36−
37− > (add:fl [%i &] [%i &])
38− [%i s=%.y]
39−
40− > (add:fl [%n ~] [%i |])
41− [%n ~]
42−
43− > (sun:fl 961.193.554.848.514.048.973.893.027.381.506.219.443)
44− [%f s=%.y e=--17 a=7.333.324.850.834.000.007.430.214.137.126.970]
45−```
46−
47−
48−---
49−### `++dn`
50−
51−Decimal float
52−
53−A mold for the floating-point arithmetic using the base of 10; the formula is
54−`(-1)^s * a *10^e`.
55−
56−Valid values are a float (`$d`), an infinity (`$i`), or a not-a-number (`$n`).
57−`s` refers to sign, the `flag`s `&` or `|`; `e` to exponent, a signed decimal;
58−and `a` to the significand, an unsigned integer.
59−
60−```hoon
61− ++ dn
62− $% [$d s=? e=@s a=@u]
63− [$i s=?]
64− [$n ~]
65− ==
66−```
67−
68−#### Examples
69−
70−```
71− > `dn`[%d & --0 17.163.091.968]
72− [%d s=%.y e=--0 a=17.163.091.968]
73−
74− > `dn`[%i s=%.y]
75− [%i s=%.y]
76−
77− > `dn`[%n ~]
78− [%n ~]
79−```
80−
81−---
82−### `++rn`
83−
84−Parsed decimal float
85−
86−A mold for the floating-point arithmetic using the base of 10; the formula is
87−`(-1)^s * a *10^e`.
88−
89−Produces either a parsed float (`$d`), infinity of either sign (`$i`), or
90−not-a-number (`$n`).
91−
92−#### Source
93−
94−```hoon
95− $% [$d a=? b=[c=@ [d=@ e=@] f=? i=@]]
96− [$i a=?]
97− [$n ~]
98− ==
99−```
100−
101−#### Examples
102−
103−```
104− > `rn`[%d | [2 [3 4] | 17.163]]
105− [%d a=%.n b=[c=2 [d=3 e=4] f=%.n i=17.163]]
106−```
107−
108−---
109−### `++fl`
110−
111−Arbitrary-precision floating-point
112−
113−Container arm for floating-point arithmetic functions.
114−
115−- Precision (`p`): number of bits in the significand; must be at least 2.
116− Default is 113.
117−- Minimum exponent (`v`): minimum value of e. Default is -16.494.
118−- Width (`w`): Max value of `e` minus min value of `e`. 0 is for fixed-point.
119− Default is 32.765.
120−- Rounding mode (`r`): Possible modes are nearest (`$n`), up (`$u`),
121− down (`$d`), to zero (`$z`), and away from zero (`$a`). Default value is `%n`.
122−- Behavior (`d`): return denormals (`$d`), flush denormals to zero (`$z`),
123− infinite exponent range (`$i`). Default value is `%d`.
124−
125−#### Source
126−
127−```hoon
128− ++ fl
129− =+ ^- [[p=@u v=@s w=@u] r=$?($n $u $d $z $a) d=$?($d $f $i)]
130− [[113 -16.494 32.765] %n %d]
131− =>
132− ~% %cofl +> ~
133− |%
134−```
135−
136−---
137−### `++rou:fl`
138−
139−Round
140−
141−Rounds `a` to a the nearest float that can be represented with a 113-bit
142−significand. There is no term to sign the significand, meaning that a positive
143−sign will always be produced.
144−
145−#### Accepts
146−
147−`a` is a cell of a signed integer and an unsigned integer.
148−
149−#### Produces
150−
151−An `fn`.
152−
153−#### Source
154−
155−```hoon
156− ++ rou
157− |= [a=[e=@s a=@u]] ^- fn (rau a &)
158−```
159−
160−#### Examples
161−
162−```
163− > =a 10.161.487.211.429.486.882.397.572.894.294.017.777
164− > (^rou:fl [--12 a])
165− [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
166−
167− > (^rou:fl [--12 (add a 1)])
168− [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
169−
170− > (^rou:fl [--12 (add a 300)])
171− [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
172−
173− > (^rou:fl [--12 (add a 1.000)])
174− [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.003]
175−```
176−
177−---
178−### `++rau:fl`
179−
180−Various roundings
181−
182−Rounds `a` based on what the state of of `r` in the core contained in `fl`. `t`
183−is a sticky bit that represents a value less than ULP(a) = 2^(e.a) when passed
184−to `lug:fl`.
185−
186−#### Accepts
187−
188−`a` is a cell of a signed integer and an unsigned integer.
189−
190−`t` is a `flag`.
191−
192−#### Produces
193−
194−An `fn`.
195−
196−#### Source
197−
198−```hoon
199− ++ rau
200− |= [a=[e=@s a=@u] t=?] ^- fn
201− ?- r
202− $z (lug %fl a t) $d (lug %fl a t)
203− $a (lug %ce a t) $u (lug %ce a t)
204− $n (lug %ne a t)
205− ==
206−```
207−
208−#### Examples
209−
210−```
211− > (rau:fl [-18 342.602.577] &)
212− [%f s=%.y e=-102 a=6.626.897.619.228.945.634.459.505.846.648.832]
213−```
214−
215−
216−#### Discussion
217−
218−See `lug:fl` for possible rounding operations.
219−
220−---
221−### `++add:fl`
222−
223−Add
224−
225−Produces the sum of `a` and `b`. `e` is used to choose between an exact result
226−(any-sized significand) or a rounded result (113-bit significand).
227−
228−There is no term to sign the significands, so a positive sign will always be
229−produced.
230−
231−#### Accepts
232−
233−`a` is an `fn`.
234−
235−`b` is an `fn`
236−
237−`e` is a `flag`.
238−
239−#### Produces
240−
241−An `fn`.
242−
243−#### Source
244−
245−```hoon
246− ++ add
247− |= [a=[e=@s a=@u] b=[e=@s a=@u] e=?] ^- fn
248− =+ q=(dif:si e.a e.b)
249− |- ?. (syn:si q) $(b a, a b, q +(q)) :: a has larger exp
250− ?: e
251− [%f & e.b (^add (lsh 0 (abs:si q) a.a) a.b)]
252− =+ [ma=(met 0 a.a) mb=(met 0 a.b)]
253− =+ ^= w %+ dif:si e.a %- sun:si :: expanded exp of a
254− ?: (gth prc ma) (^sub prc ma) 0
255− =+ ^= x %+ sum:si e.b (sun:si mb) :: highest exp for b
256− ?: =((cmp:si w x) --1) :: don't need to add
257− ?- r
258− $z (lug %fl a &) $d (lug %fl a &)
259− $a (lug %lg a &) $u (lug %lg a &)
260− $n (lug %na a &)
261− ==
262− (rou [e.b (^add (lsh 0 (abs:si q) a.a) a.b)])
263−```
264−
265−#### Examples
266−
267−```
268− > (^add:fl [--33 2.718] [--23 11] %.y)
269− [%f s=%.y e=--23 a=2.783.243]
270−
271− > (^add:fl [--33 2.718] [--23 11] %.n)
272− [%f s=%.y e=-68 a=6.890.975.897.521.519.304.902.126.405.156.864]
273−```
274−
275−---
276−### `++sub:fl`
277−
278−Subtract
279−
280−Produces the difference of `a` minus `b.` `e` is used to choose between an exact
281−result (any-sized significand) or a rounded result (113-bit significand).
282−
283−#### Accepts
284−
285−`a` is a cell of a signed integer and an unsigned integer.
286−
287−`b` is a cell of a signed integer and an unsigned integer.
288−
289−`e` is a `flag`.
290−
291−#### Produces
292−
293−An `fn`.
294−
295−#### Source
296−
297−```hoon
298− ++ sub
299− |= [a=[e=@s a=@u] b=[e=@s a=@u] e=?] ^- fn
300− =+ q=(dif:si e.a e.b)
301− |- ?. (syn:si q)
302− (fli $(b a, a b, q +(q), r swr))
303− =+ [ma=(met 0 a.a) mb=(met 0 a.b)]
304− =+ ^= w %+ dif:si e.a %- sun:si
305− ?: (gth prc ma) (^sub prc ma) 0
306− =+ ^= x %+ sum:si e.b (sun:si +(mb))
307− ?: &(!e =((cmp:si w x) --1))
308− ?- r
309− $z (lug %sm a &) $d (lug %sm a &)
310− $a (lug %ce a &) $u (lug %ce a &)
311− $n (lug %nt a &)
312− ==
313− =+ j=(lsh 0 (abs:si q) a.a)
314− |- ?. (gte j a.b)
315− (fli $(a.b j, j a.b, r swr))
316− =+ i=(^sub j a.b)
317− ?~ i [%f & zer]
318− ?: e [%f & e.b i] (rou [e.b i])
319−```
320−
321−#### Examples
322−
323−```
324− > (^sub:fl [--33 2.718] [--23 11] %.y)
325− [%f s=%.y e=--23 a=2.783.221]
326−
327− > (^sub:fl [--33 2.718] [--63 11] %.y)
328− [%f s=%.n e=--33 a=11.811.157.346]
329−```
330−
331−---
332−### `++mul:fl`
333−
334−Multiply
335−
336−Produces the product of `a` multiplied by `b`. There is no term to sign the
337−significands, so a positive sign will always be produced.
338−
339−#### Accepts
340−
341−`a` is a cell of a signed integer and an unsigned integer.
342−
343−`b` is a cell of a signed integer and an unsigned integer.
344−
345−#### Produces
346−
347−An `fn`.
348−
349−#### Source
350−
351−```hoon
352− ++ mul
353− |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- fn
354− (rou (sum:si e.a e.b) (^mul a.a a.b))
355−```
356−
357−#### Examples
358−
359−```
360− > (^mul:fl [--3 2.718] [--23 11])
361− [%f s=%.y e=-72 a=9.475.054.411.405.900.661.487.108.108.582.912]
362−```
363−
364−---
365−### `++div:fl`
366−
367−Divide
368−
369−Produces the quotient of `a` divided by `b`. There is no term to sign the
370−significands, so a positive sign will always be produced.
371−
372−#### Accepts
373−
374−`a` is a cell of a signed integer and an unsigned integer.
375−
376−`b` is a cell of a signed integer and an unsigned integer.
377−
378−#### Produces
379−
380−An `fn`.
381−
382−#### Source
383−
384−```hoon
385− ++ div
386− |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- fn
387− =+ [ma=(met 0 a.a) mb=(met 0 a.b)]
388− =+ v=(dif:si (sun:si ma) (sun:si +((^add mb prc))))
389− =. a ?: (syn:si v) a
390− a(e (sum:si v e.a), a (lsh 0 (abs:si v) a.a))
391− =+ [j=(dif:si e.a e.b) q=(dvr a.a a.b)]
392− (rau [j p.q] =(q.q 0))
393−```
394−
395−#### Examples
396−
397−```
398− > (^div:fl [--13 2.718] [--23 11])
399− [%f s=%.y e=-115 a=10.023.198.055.040.952.765.870.659.817.343.907]
400−```
401−
402−---
403−### `++sqt:fl`
404−
405−Square root
406−
407−Produces the square root of `a`.
408−
409−#### Accepts
410−
411−`a` is a cell of a signed integer and an unsigned integer.
412−
413−#### Produces
414−
415−An `fn`.
416−
417−#### Source
418−
419−```hoon
420− ++ sqt
421− |= [a=[e=@s a=@u]] ^- fn
422− =. a
423− =+ [w=(met 0 a.a) x=(^mul +(prc) 2)]
424− =+ ?:((^lth w x) (^sub x w) 0)
425− =+ ?: =((dis - 1) (dis (abs:si e.a) 1)) -
426− (^add - 1)
427− a(e (dif:si e.a (sun:si -)), a (lsh 0 - a.a))
428− =+ [y=(^sqt a.a) z=(fra:si e.a --2)]
429− (rau [z p.y] =(q.y 0))
430−```
431−
432−#### Examples
433−
434−```
435− > (^sqt:fl [-18 342.602.577])
436− [%f s=%.y e=-107 a=5.865.903.143.604.945.574.132.671.852.050.553]
437−```
438−
439−---
440−### `++lth:fl`
441−
442−Less than
443−
444−Tests if `a` is less than `b`.
445−
446−#### Accepts
447−
448−`a` is a cell of a signed integer and an unsigned integer.
449−
450−`b` is a cell of a signed integer and an unsigned integer.
451−
452−#### Produces
453−
454−An `flag`.
455−
456−#### Source
457−
458−```hoon
459− ++ lth
460− |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- ?
461− ?: =(e.a e.b) (^lth a.a a.b)
462− =+ c=(cmp:si (ibl a) (ibl b))
463− ?: =(c -1) & ?: =(c --1) |
464− ?: =((cmp:si e.a e.b) -1)
465− (^lth (rsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b)
466− (^lth (lsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b)
467−```
468−
469−#### Examples
470−
471−```
472− > (^lth:fl [-4 684] [--0 35])
473− %.n
474−
475− > (^lth:fl [-4 684] [--0 90])
476− %.y
477−```
478−
479−---
480−### `++equ:fl`
481−
482−Equals
483−
484−Tests if `a` is equal to `b`.
485−
486−#### Accepts
487−
488−`a` is a cell of a signed integer and an unsigned integer.
489−
490−`b` is a cell of a signed integer and an unsigned integer.
491−
492−#### Produces
493−
494−A `flag`.
495−
496−#### Source
497−
498−```hoon
499− ++ equ
500− |= [a=[e=@s a=@u] b=[e=@s a=@u]] ^- ?
501− ?. =((ibl a) (ibl b)) |
502− ?: =((cmp:si e.a e.b) -1)
503− =((lsh 0 (abs:si (dif:si e.a e.b)) a.b) a.a)
504− =((lsh 0 (abs:si (dif:si e.a e.b)) a.a) a.b)
505−```
506−
507−#### Examples
508−
509−```
510− > (^equ:fl [-4 480] [-0 50])
511− %.n
512−
513− > (^equ:fl [-4 480] [-0 30])
514− %.y
515−```
516−
517−---
518−### `++ibl:fl`
519−
520−Integer binary logarithm
521−
522−Produces the lowest power to which the number 2 must be raised to obtain `a` or
523−greater.
524−
525−#### Accepts
526−
527−`a` is a cell of a signed integer and an unsigned integer.
528−
529−#### Produces
530−
531−A signed integer.
532−
533−#### Source
534−
535−```hoon
536− ++ ibl
537− |= [a=[e=@s a=@u]] ^- @s
538− (sum:si (sun:si (dec (met 0 a.a))) e.a)
539−```
540−
541−#### Examples
542−
543−```
544− > (ibl:fl [-18 342.602.577])
545− --10
546−```
547−
548−---
549−### `++uni:fl`
550−
551−Change representation to odd
552−
553−Produces another representation of the floating point `a` where the significand
554−is odd. Every floating-point number has a unique representation of this kind. If
555−the significand of `a` is already odd, nothing changes.
556−
557−#### Accepts
558−
559−`a` is a cell of a signed integer and an unsigned integer.
560−
561−#### Produces
562−
563−A cell of a signed integer and an unsigned integer.
564−
565−#### Source
566−
567−```hoon
568− ++ uni
569− |= [a=[e=@s a=@u]]
570− |- ?: =((end 0 1 a.a) 1) a
571− $(a.a (rsh 0 1 a.a), e.a (sum:si e.a --1))
572−```
573−
574−#### Examples
575−
576−```
577− > (uni:fl [-8 342.602.578])
578− [e=-7 a=171.301.289]
579−
580− > (uni:fl [-8 342.602.577])
581− [e=-8 a=342.602.577]
582−```
583−
584−---
585−### `++xpd:fl`
586−
587−Expand
588−
589−Produces the fully precise form of `a`, or the denormalized form of `a`.
590−
591−#### Accepts
592−
593−`a` is a cell of a signed integer and an unsigned integer.
594−
595−#### Produces
596−
597−A cell of a signed integer and an unsigned integer.
598−
599−#### Sources
600−
601−```hoon
602− ++ xpd
603− |= [a=[e=@s a=@u]]
604− =+ ma=(met 0 a.a)
605− ?: (gte ma prc) a
606− =+ ?: =(den %i) (^sub prc ma)
607− =+ ^= q
608− =+ w=(dif:si e.a emn)
609− ?: (syn:si w) (abs:si w) 0
610− (min q (^sub prc ma))
611− a(e (dif:si e.a (sun:si -)), a (lsh 0 - a.a))
612−```
613−
614−#### Examples
615−
616−```
617− > (xpd:fl [--3 12])
618− [e=-106 a=7.788.445.287.802.241.442.795.744.493.830.144]
619−
620− > (xpd:fl [-8 342.602.577])
621− [e=-92 a=6.626.897.619.228.945.634.459.505.846.648.832]
622−
623− > (xpd:fl [-92 6.626.897.619.228.945.634.459.505.846.648.832])
624− [e=-92 a=6.626.897.619.228.945.634.459.505.846.648.832]
625−```
626−
627−---
628−### `++lug:fl`
629−
630−Central rounding mechanism
631−
632−Performs various rounding operations on `a`. An operation is chosen based on the
633−value selected for `t`. `s` is a sticky bit that represents a value less than
634−ULP(a) = 2^(e.a)
635−
636−Possible rounding operations:
637−- Floor (`$fl`)
638−- Ceiling (`$ce`)
639−- Smaller (`$sm`)
640−- Larger (`$lg`)
641−- Nearest (`$ne`) -- Rounds ties away from 0 if the number is even, rounds
642− toward 0 if the number is odd.
643−
644−#### Accepts
645−
646−`t` is one of the following: `$fl`, `$ce`, `$sm`, `$lg`, `$ne`, `$na`, or `$nt`.
647−
648−`a` is a cell of a signed integer and an unsigned integer.
649−
650−`s` is a flag.
651−
652−#### Produces
653−
654−An `fn`.
655−
656−#### Source
657−
658−```hoon
659− ::
660− :: central rounding mechanism
661− :: can perform: floor, ceiling, smaller, larger,
662− :: nearest (round ties to: even, away from 0, toward 0)
663− :: s is sticky bit: represents a value less than ulp(a) = 2^(e.a)
664− ::
665− ++ lug
666− ~/ %lug
667− |= [t=$?($fl $ce $sm $lg $ne $na $nt) a=[e=@s a=@u] s=?] ^- fn
668− ?< =(a.a 0)
669− =-
670− ?. =(den %f) - :: flush denormals
671− ?. ?=([$f *] -) -
672− ?: =((met 0 ->+>) prc) - [%f & zer]
673− ::
674− =+ m=(met 0 a.a)
675− ?> |(s (gth m prc)) :: require precision
676− =+ ^= q %+ max
677− ?: (gth m prc) (^sub m prc) 0 :: reduce precision
678− %- abs:si ?: =(den %i) --0 :: enforce min. exp
679− ?: =((cmp:si e.a emn) -1) (dif:si emn e.a) --0
680− =^ b a :- (end 0 q a.a)
681− a(e (sum:si e.a (sun:si q)), a (rsh 0 q a.a))
682− ::
683− ?~ a.a
684− ?< =(den %i)
685− ?- t
686− $fl [%f & zer]
687− $sm [%f & zer]
688− $ce [%f & spd]
689− $lg [%f & spd]
690− $ne ?: s [%f & ?:((lte b (bex (dec q))) zer spd)]
691− [%f & ?:((^lth b (bex (dec q))) zer spd)]
692− $nt ?: s [%f & ?:((lte b (bex (dec q))) zer spd)]
693− [%f & ?:((^lth b (bex (dec q))) zer spd)]
694− $na [%f & ?:((^lth b (bex (dec q))) zer spd)]
695− ==
696− ::
697− =. a (xpd a)
698− ::
699− =. a
700− ?- t
701− $fl a
702− $lg a(a +(a.a))
703− $sm ?. &(=(b 0) s) a
704− ?: &(=(e.a emn) !=(den %i)) a(a (dec a.a))
705− =+ y=(dec (^mul a.a 2))
706− ?. (lte (met 0 y) prc) a(a (dec a.a))
707− [(dif:si e.a --1) y]
708− $ce ?: &(=(b 0) s) a a(a +(a.a))
709− $ne ?~ b a
710− =+ y=(bex (dec q))
711− ?: &(=(b y) s) :: round halfs to even
712− ?~ (dis a.a 1) a a(a +(a.a))
713− ?: (^lth b y) a a(a +(a.a))
714− $na ?~ b a
715− =+ y=(bex (dec q))
716− ?: (^lth b y) a a(a +(a.a))
717− $nt ?~ b a
718− =+ y=(bex (dec q))
719− ?: =(b y) ?: s a a(a +(a.a))
720− ?: (^lth b y) a a(a +(a.a))
721− ==
722− ::
723− =. a ?. =((met 0 a.a) +(prc)) a
724− a(a (rsh 0 1 a.a), e (sum:si e.a --1))
725− ?~ a.a [%f & zer]
726− ::
727− ?: =(den %i) [%f & a]
728− ?: =((cmp:si emx e.a) -1) [%i &] [%f & a] :: enforce max. exp
729− ::
730−```
731−
732−---
733−### `++drg:fl`
734−
735−Get printable decimal
736−
737−Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
738−accurate results for rounded floats.
739−
740−#### Accepts
741−
742−`a` is a cell of a signed integer and an unsigned integer.
743−
744−#### Produces
745−
746−A cell of a signed integer and an unsigned integer.
747−
748−#### Source
749−
750−```hoon
751− ++ drg
752− ~/ %drg
753− |= [a=[e=@s a=@u]] ^- [@s @u]
754− ?< =(a.a 0)
755− =. a (xpd a)
756− =+ r=(lsh 0 ?:((syn:si e.a) (abs:si e.a) 0) a.a)
757− =+ s=(lsh 0 ?.((syn:si e.a) (abs:si e.a) 0) 1)
758− =+ mn=(lsh 0 ?:((syn:si e.a) (abs:si e.a) 0) 1)
759− =+ mp=mn
760− => ?.
761− ?& =(a.a (bex (dec prc))) :: if next smallest
762− |(!=(e.a emn) =(den %i)) :: float is half ULP,
763− == :: tighten lower bound
764− .
765− %= .
766− mp (lsh 0 1 mp)
767− r (lsh 0 1 r)
768− s (lsh 0 1 s)
769− ==
770− =+ [k=--0 q=(^div (^add s 9) 10)]
771− |- ?: (^lth r q)
772− %= $
773− k (dif:si k --1)
774− r (^mul r 10)
775− mn (^mul mn 10)
776− mp (^mul mp 10)
777− ==
778− |- ?: (gte (^add (^mul r 2) mp) (^mul s 2))
779− $(s (^mul s 10), k (sum:si k --1))
780− =+ [u=0 o=0]
781− |- :: r/s+o = a*10^-k
782− =+ v=(dvr (^mul r 10) s)
783− => %= .
784− k (dif:si k --1)
785− u p.v
786− r q.v
787− mn (^mul mn 10)
788− mp (^mul mp 10)
789− ==
790− =+ l=(^lth (^mul r 2) mn) :: in lower bound
791− =+ ^= h :: in upper bound
792− ?| (^lth (^mul s 2) mp)
793− (gth (^mul r 2) (^sub (^mul s 2) mp))
794− ==
795− ?: &(!l !h)
796− $(o (^add (^mul o 10) u))
797− =+ q=&(h |(!l (gth (^mul r 2) s)))
798− =. o (^add (^mul o 10) ?:(q +(u) u))
799− [k o]
800−```
801−
802−#### Examples
803−
804−```
805− > (sun:fl 218.116)
806− [%f s=%.y e=-95 a=8.640.464.947.480.640.129.276.716.135.743.488]
807− > (^drg:fl [e=-95 a=8.640.464.947.480.640.129.276.716.135.743.488])
808− [--0 218.116]
809−
810− > (sun:fl 102.057.673.128.349)
811− [%f s=%.y e=-66 a=7.530.527.107.827.833.883.675.587.233.447.936]
812− > (^drg:fl [e=-66 a=7.530.527.107.827.833.883.675.587.233.447.936])
813− [--0 102.057.673.128.349]
814−```
815−
816−---
817−### `++toj:fl`
818−
819−Round to integer
820−
821−Rounds float `a` to the nearest decimal float with an exponent of 0.
822−
823−#### Accepts
824−
825−`a` is a cell of a signed integer and an unsigned integer.
826−
827−#### Produces
828−
829−An `fn`.
830−
831−#### Source
832−
833−```hoon
834− ++ toj
835− |= [a=[e=@s a=@u]] ^- fn
836− ?. =((cmp:si e.a --0) -1) [%f & a]
837− =+ x=(abs:si e.a)
838− =+ y=(rsh 0 x a.a)
839− ?: |(=(r %d) =(r %z)) [%f & --0 y]
840− =+ z=(end 0 x a.a)
841− ?: |(=(r %u) =(r %a)) [%f & --0 ?~(z y +(y))]
842− =+ i=(bex (dec x))
843− ?: &(=(z i) =((dis y 1) 0)) [%f & --0 y]
844− ?: (^lth z i) [%f & --0 y] [%f & --0 +(y)]
845−```
846−
847−#### Examples
848−
849−```
850− > (^toj:fl [-11 7.530.107.827.833.587])
851− [%f s=%.y e=--0 a=3.676.810.462.809]
852−
853− > (^toj:fl [-11 7.530.107.827.833.589])
854− [%f s=%.y e=--0 a=3.676.810.462.809]
855−```
856−
857−---
858−### `++ned:fl`
859−
860−Require float
861−
862−Produces `a` if `a` is a is of floating-point representation. If `a` is another
863−case of `fn`, such as infinity or not-a-number, a crash is produced.
864−
865−#### Accepts
866−
867−`a` is an `fn`.
868−
869−#### Produces
870−
871−A cell of a signed integer and an unsigned integer.
872−
873−#### Source
874−
875−```hoon
876− ++ ned
877− |= [a=fn] ^- [$f s=? e=@s a=@u]
878− ?: ?=([$f *] a) a
879− ~_ leaf+"need-float"
880− !!
881−```
882−
883−#### Examples
884−
885−
886−```
887− > (ned:fl [%f s=%.y e=-11 a=7.530.107.827.833.587])
888− [%f s=%.y e=-11 a=7.530.107.827.833.587]
889−
890− > (ned:fl [%n ~])
891− ! need-float
892− ! exit
893−
894− > (ned:fl [%i |])
895− ! need-float
896− ! exit
897−```
898−
899−---
900−### `++shf:fl`
901−
902−Shift power
903−
904−Multiplies `a` by 2 to the `b` power without rounding. This results in shifting
905−the exponent term by `b`.
906−
907−#### Accepts
908−
909−`a` is an `fn`.
910−
911−`b` is a signed integer.
912−
913−#### Produces
914−
915−An `fn`.
916−
917−#### Source
918−
919−```hoon
920− ++ shf
921− |= [a=fn b=@s]
922− ?: |(?=([$n *] a) ?=([$i *] a)) a
923− a(e (sum:si e.a b))
924−```
925−
926−#### Examples
927−
928−```
929− > (shf:fl [[%f & -2 7] --2])
930− [%f s=%.y e=--0 a=7]
931−
932− > (shf:fl [[%f & -2 7] -2])
933− [%f s=%.y e=-4 a=7]
934−
935− > (shf:fl [%f & -11 7.530.107.827.833.587] --5)
936− [%f s=%.y e=-6 a=7.530.107.827.833.587]
937−```
938−
939−---
940−### `++fli:fl`
941−
942−Flip sign
943−
944−Produces `a` with its signed changed from positive to negative, or vice versa.
945−
946−#### Accepts
947−
948−`a` is an `fn`.
949−
950−#### Produces
951−
952−An `fn`.
953−
954−#### Source
955−
956−```hoon
957− ++ fli
958− |= [a=fn] ^- fn
959− ?-(-.a $f a(s !s.a), $i a(s !s.a), $n a)
960−```
961−
962−#### Examples
963−
964−```
965− > (fli:fl [%f %.y -2 7])
966− [%f s=%.n e=-2 a=7]
967−
968− > (fli:fl [%f %.n --2 30.617])
969− [%f s=%.y e=--2 a=30.617]
970−
971− > (fli:fl [%f | --2 30.617])
972− [%f s=%.y e=--2 a=30.617]
973−```
974−
975−---
976−### `++swr:fl`
977−
978−Switch rounding
979−
980−Switches the rounding mode of `r:fl`.
981−
982−#### Source
983−
984−```hoon
985− ++ swr ?+(r r $d %u, $u %d)
986−```
987−
988−#### Examples
989−
990−```
991− > r:fl
992− %n
993− > swr:fl
994− %n
995−
996− > =new-fl fl :: new fl core with changed state
997− > =new-fl new-fl(r %u)
998− > swr:new-fl
999− %d
1000−```
1001−
1002−---
1003−### `++prc:fl`
1004−
1005−Force precision of 2 or greater
1006−
1007−Produces `p`, the core's precision, if `p` is greater than or equal to 2.
1008−Otherwise, a crash is produced.
1009−
1010−#### Source
1011−
1012−```hoon
1013− ++ prc ?>((gth p 1) p)
1014−```
1015−
1016−#### Examples
1017−
1018−```
1019− > prc:fl
1020− 113
1021−
1022− > =new-fl fl
1023− > =new-fl new-fl(p 1)
1024− > prc:new-fl
1025− ! exit
1026−
1027− > =new-fl new-fl(p 2)
1028− > prc:new-fl
1029− 2
1030−```
1031−
1032−---
1033−### `++den:fl`
1034−
1035−Behavior
1036−
1037−Produces `d:fl`. Denormalizes if `d:fl` is `%d`. Flushes denormals to zero if
1038−`d:fl` is `%f`.
1039−
1040−- Denormalizes if `d:fl` is `%d`.
1041−- Flushes denormals to zero if `d:fl` is `%f`.
1042−- Infinite exponent range if `$d` is `$i`.
1043−
1044−The default value of `d` is `%d`.
1045−
1046−#### Source
1047−
1048−```hoon
1049− ++ den d
1050−```
1051−
1052−#### Examples
1053−
1054−```
1055− > den:fl
1056− %d
1057−
1058− > =new-fl fl
1059− > =new-fl new-fl(d %f)
1060− > den:new-fl
1061− %f
1062−```
1063−
1064−---
1065−### `++emn:fl`
1066−
1067−Minimum exponent
1068−
1069−Produces `v:fl`, the minimum exponent. The default minimum exponent is -16.494.
1070−
1071−#### Source
1072−
1073−```hoon
1074− ++ emn v
1075−```
1076−
1077−#### Examples
1078−
1079−```
1080− > emn:fl
1081− -16.494
1082−```
1083−
1084−---
1085−### `++emx:fl`
1086−
1087−Maximum exponent
1088−
1089−Returns the maximum exponent of `fl`. The default maximum exponent is --16.271.
1090−
1091−#### Source
1092−
1093−```hoon
1094− ++ emx (sum:si emn (sun:si w))
1095−```
1096−
1097−#### Examples
1098−
1099−```
1100− > emx:fl
1101− --16.271
1102−
1103− > `@u`emx:fl
1104− 32.542
1105−```
1106−
1107−---
1108−### `++spd:fl`
1109−
1110−Smallest denormal
1111−
1112−Produces the smallest possible denormalized float.
1113−
1114−#### Source
1115−
1116−```hoon
1117− ++ spd [e=emn a=1]
1118−```
1119−
1120−#### Examples
1121−
1122−```
1123− > spd:fl
1124− [e=-16.494 a=1]
1125−```
1126−
1127−---
1128−### `++spn:fl`
1129−
1130−Smallest normal
1131−
1132−Produces the smallest representable normal float.
1133−
1134−#### Source
1135−
1136−```hoon
1137− ++ spn [e=emn a=(bex (dec prc))]
1138−```
1139−
1140−#### Examples
1141−
1142−```
1143− > spn:fl
1144− [e=-16.494 a=5.192.296.858.534.827.628.530.496.329.220.096]
1145−```
1146−
1147−---
1148−### `++lfn:fl`
1149−
1150−Largest normal
1151−
1152−Produces the largest representable normal float.
1153−
1154−#### Source
1155−
1156−```hoon
1157− ++ lfn [e=emx a=(fil 0 prc 1)]
1158−```
1159−
1160−#### Examples
1161−
1162−```
1163− > lfn:fl
1164− [e=--16.271 a=10.384.593.717.069.655.257.060.992.658.440.191]
1165−```
1166−
1167−---
1168−### `++lfe:fl`
1169−
1170−Maximum
1171−
1172−Produces the sum of `emx:fl` plus `prc:fl`.
1173−
1174−#### Source
1175−
1176−```hoon
1177− ++ lfe (sum:si emx (sun:si prc)) :: 2^lfe is > than all
1178−```
1179−
1180−#### Examples
1181−
1182−```
1183− > lfe:fl
1184− --16.384
1185−```
1186−
1187−---
1188−### `++zer:fl`
1189−
1190−Zero
1191−
1192−Produces zero represented as a float.
1193−
1194−#### Source
1195−
1196−```hoon
1197− ++ zer [e=--0 a=0]
1198− --
1199− |%
1200−```
1201−
1202−#### Examples
1203−
1204−```
1205− > zer:fl
1206− [e=--0 a=0]
1207−```
1208−
1209−---
1210−### `++rou:fl`
1211−
1212−Round
1213−
1214−Rounds `a`. The way in which `a` is rounded depends on the value of `r:fl`.
1215−
1216−#### Accepts
1217−
1218−`a` is an `fn`.
1219−
1220−#### Produes
1221−
1222−An `fn`.
1223−
1224−#### Source
1225−
1226−```hoon
1227− ++ rou
1228− |= [a=fn] ^- fn
1229− ?. ?=([$f *] a) a
1230− ?~ a.a [%f s.a zer]
1231− ?: s.a (^rou +>.a)
1232− =.(r swr (fli (^rou +>.a)))
1233−```
1234−
1235−#### Examples
1236−
1237−```
1238− > =a 10.161.487.211.429.486.882.397.572.894.294.017.777
1239− > (rou:fl [%f & --12 a])
1240− [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
1241−
1242− > (rou:fl [%f & --12 (add a 1)])
1243− [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
1244−
1245− > (rou:fl [%f & --12 (add a 300)])
1246− [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.002]
1247−
1248− > (rou:fl [%f & --12 (add a 1.000)])
1249− [%f s=%.y e=--22 a=9.923.327.354.911.608.283.591.379.779.584.003]
1250−```
1251−
1252−---
1253−### `++syn:fl`
1254−
1255−Get sign
1256−
1257−Produces the sign of `a`.
1258−
1259−#### Accepts
1260−
1261−`a` is an `fn`.
1262−
1263−#### Produes
1264−
1265−An `fn`.
1266−
1267−#### Source
1268−
1269−```hoon
1270− ++ syn
1271− |= [a=fn] ^- ?
1272− ?-(-.a $f s.a, $i s.a, $n &)
1273−```
1274−
1275−#### Examples
1276−
1277−```
1278− > (syn:fl (sun:fl 106))
1279− %.y
1280−
1281− > (syn:fl [%f | --0 106])
1282− %.n
1283−```
1284−
1285−---
1286−### `++abs:fl`
1287−
1288−Absolute value
1289−
1290−Produces the absolute value of `a`.
1291−
1292−#### Accepts
1293−
1294−`a` is an `fn`.
1295−
1296−#### Produes
1297−
1298−An `fn`.
1299−
1300−#### Sources
1301−
1302−```hoon
1303− ++ abs
1304− |= [a=fn] ^- fn
1305− ?: ?=([$f *] a) [%f & e.a a.a]
1306− ?: ?=([$i *] a) [%i &] [%n ~]
1307−```
1308−
1309−#### Examples
1310−
1311−```
1312− > (abs:fl [%f | --0 106])
1313− [%f s=%.y e=--0 a=106]
1314−
1315− > (abs:fl [%f & --0 106])
1316− [%f s=%.y e=--0 a=106]
1317−```
1318−
1319−---
1320−### `++add:fl`
1321−
1322−Add
1323−
1324−Produces the sum of `a` plus `b`.
1325−
1326−#### Accepts
1327−
1328−`a` is an `fn`.
1329−
1330−`b` is an `fn`.
1331−
1332−#### Produces
1333−
1334−An `fn`.
1335−
1336−#### Source
1337−
1338−```hoon
1339− ++ add
1340− |= [a=fn b=fn] ^- fn
1341− ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1342− ?: |(?=([$i *] a) ?=([$i *] b))
1343− ?: &(?=([$i *] a) ?=([$i *] b))
1344− ?: =(a b) a [%n ~]
1345− ?: ?=([$i *] a) a b
1346− ?: |(=(a.a 0) =(a.b 0))
1347− ?. &(=(a.a 0) =(a.b 0)) %- rou ?~(a.a b a)
1348− [%f ?:(=(r %d) &(s.a s.b) |(s.a s.b)) zer]
1349− %- |= [a=fn]
1350− ?. ?=([$f *] a) a
1351− ?. =(a.a 0) a
1352− [%f !=(r %d) zer]
1353− ?: =(s.a s.b)
1354− ?: s.a (^add +>.a +>.b |)
1355− =.(r swr (fli (^add +>.a +>.b |)))
1356− ?: s.a (^sub +>.a +>.b |)
1357− (^sub +>.b +>.a |)
1358−```
1359−
1360−#### Examples
1361−
1362−```
1363− > (add:fl [%f & --0 106] [%f | --3 55])
1364− [%f s=%.n e=-104 a=6.774.324.807.619.657.921.598.381.929.529.344]
1365−```
1366−
1367−---
1368−### `++ead:fl`
1369−
1370−Exact add
1371−
1372−Produces the exact sum of `a` plus `b`.
1373−
1374−#### Accepts
1375−
1376−`a` is an `fn`.
1377−
1378−`b` is an `fn`.
1379−
1380−#### Produces
1381−
1382−An `fn`.
1383−
1384−#### Source
1385−
1386−```hoon
1387− ++ ead
1388− |= [a=fn b=fn] ^- fn
1389− ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1390− ?: |(?=([$i *] a) ?=([$i *] b))
1391− ?: &(?=([$i *] a) ?=([$i *] b))
1392− ?: =(a b) a [%n ~]
1393− ?: ?=([$i *] a) a b
1394− ?: |(=(a.a 0) =(a.b 0))
1395− ?. &(=(a.a 0) =(a.b 0)) ?~(a.a b a)
1396− [%f ?:(=(r %d) &(s.a s.b) |(s.a s.b)) zer]
1397− %- |= [a=fn]
1398− ?. ?=([$f *] a) a
1399− ?. =(a.a 0) a
1400− [%f !=(r %d) zer]
1401− ?: =(s.a s.b)
1402− ?: s.a (^add +>.a +>.b &)
1403− (fli (^add +>.a +>.b &))
1404− ?: s.a (^sub +>.a +>.b &)
1405− (^sub +>.b +>.a &)
1406− ::
1407−```
1408−
1409−#### Examples
1410−
1411−```
1412− > (ead:fl [%f & --0 106] [%f | --3 55])
1413− [%f s=%.n e=--0 a=334]
1414−```
1415−
1416−---
1417−### `++sub:fl`
1418−
1419−Subtract
1420−
1421−Produces the difference of `a` minus `b`.
1422−
1423−#### Accepts
1424−
1425−`a` is an `fn`.
1426−
1427−`b` is an `fn`.
1428−
1429−#### Produces
1430−
1431−An `fn`.
1432−
1433−#### Source
1434−
1435−```hoon
1436− ++ sub
1437− |= [a=fn b=fn] ^- fn (add a (fli b))
1438−```
1439−
1440−#### Examples
1441−
1442−```
1443− > (sub:fl [%f & --13 2.718] [%f & --23 11])
1444− [%f s=%.n e=-86 a=5.416.671.014.775.224.232.595.412.796.571.648]
1445−```
1446−
1447−---
1448−### `++mul:fl`
1449−
1450−Multiply
1451−
1452−Produces the product of `a` multiplied by `b`.
1453−
1454−#### Accepts
1455−
1456−`a` is an `fn`.
1457−
1458−`b` is an `fn`.
1459−
1460−#### Produces
1461−
1462−An `fn`.
1463−
1464−#### Source
1465−
1466−```hoon
1467− ++ mul
1468− |= [a=fn b=fn] ^- fn
1469− ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1470− ?: ?=([$i *] a)
1471− ?: ?=([$i *] b)
1472− [%i =(s.a s.b)]
1473− ?: =(a.b 0) [%n ~] [%i =(s.a s.b)]
1474− ?: ?=([$i *] b)
1475− ?: =(a.a 0) [%n ~] [%i =(s.a s.b)]
1476− ?: |(=(a.a 0) =(a.b 0)) [%f =(s.a s.b) zer]
1477− ?: =(s.a s.b) (^mul +>.a +>.b)
1478− =.(r swr (fli (^mul +>.a +>.b)))
1479−```
1480−
1481−---
1482−### `++emu:fl`
1483−
1484−Exact multiply
1485−
1486−Produces the exact product of `a` multiplied by `b`.
1487−
1488−#### Accepts
1489−
1490−`a` is an `fn`.
1491−
1492−`b` is an `fn`.
1493−
1494−#### Produces
1495−
1496−An `fn`.
1497−
1498−#### Examples
1499−
1500−```
1501− ++ emu
1502− |= [a=fn b=fn] ^- fn
1503− ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1504− ?: ?=([$i *] a)
1505− ?: ?=([$i *] b)
1506− [%i =(s.a s.b)]
1507− ?: =(a.b 0) [%n ~] [%i =(s.a s.b)]
1508− ?: ?=([$i *] b)
1509− ?: =(a.a 0) [%n ~] [%i =(s.a s.b)]
1510− ?: |(=(a.a 0) =(a.b 0)) [%f =(s.a s.b) zer]
1511− [%f =(s.a s.b) (sum:si e.a e.b) (^^mul a.a a.b)]
1512−```
1513−
1514−---
1515−### `++div:fl`
1516−
1517−Divide
1518−
1519−Produces the quotient of `a` divided by `b`.
1520−
1521−#### Accepts
1522−
1523−`a` is an `fn`.
1524−
1525−`b` is an `fn`.
1526−
1527−#### Produces
1528−
1529−An `fn`.
1530−
1531−#### Divide
1532−
1533−```hoon
1534− ++ div
1535− |= [a=fn b=fn] ^- fn
1536− ?: |(?=([$n *] a) ?=([$n *] b)) [%n ~]
1537− ?: ?=([$i *] a)
1538− ?: ?=([$i *] b) [%n ~] [%i =(s.a s.b)]
1539− ?: ?=([$i *] b) [%f =(s.a s.b) zer]
1540− ?: =(a.a 0) ?: =(a.b 0) [%n ~] [%f =(s.a s.b) zer]
1541− ?: =(a.b 0) [%i =(s.a s.b)]
1542− ?: =(s.a s.b) (^div +>.a +>.b)
1543− =.(r swr (fli (^div +>.a +>.b)))
1544−```
1545−
1546−---
1547−### `++fma:fl`
1548−
1549−Fused multiply-add
1550−
1551−Produces the sum of `c` plus the product of `a` multiplied by `b`;
1552−`(a * b) + c`.
1553−
1554−#### Accepts
1555−
1556−`a` is an `fn`.
1557−
1558−`b` is an `fn`.
1559−
1560−`c` is an `fn`.
1561−
1562−#### Produces
1563−
1564−An `fn`.
1565−
1566−#### Source
1567−
1568−```hoon
1569− ++ fma
1570− |= [a=fn b=fn c=fn] ^- fn
1571− (add (emu a b) c)
1572−```
1573−
1574−#### Examples
1575−
1576−```
1577− > (fma:fl [%f & --13 2.718] [%f & --23 11] [%f & --13 2.718])
1578− [%f s=%.y e=-62 a=9.475.054.514.089.037.465.004.673.635.188.736]=
1579−```
1580−
1581−---
1582−### `++sqt:fl`
1583−
1584−Square root
1585−
1586−Produces the square root of `a`.
1587−
1588−#### Accepts
1589−
1590−`a` is an `fn`.
1591−
1592−#### Produces
1593−
1594−An `fn`.
1595−
1596−#### Source
1597−
1598−```hoon
1599− ++ sqt
1600− |= [a=fn] ^- fn
1601− ?: ?=([$n *] a) [%n ~]
1602− ?: ?=([$i *] a) ?:(s.a a [%n ~])
1603− ?~ a.a [%f s.a zer]
1604− ?: s.a (^sqt +>.a) [%n ~]
1605−```
1606−
1607−#### Examples
1608−
1609−```
1610− > (sqt:fl [%f s=%.y e=-18 a=342.602.577])
1611− [%f s=%.y e=-107 a=5.865.903.143.604.945.574.132.671.852.050.553]
1612−```
1613−
1614−---
1615−### `++inv:fl`
1616−
1617−Inverse
1618−
1619−Produces the inverse of `a` by dividing `1` by `a`.
1620−
1621−#### Accepts
1622−
1623−`a` is an `fn`.
1624−
1625−#### Produces
1626−
1627−An `fn`.
1628−
1629−#### Source
1630−
1631−```hoon
1632− ++ inv
1633− |= [a=fn] ^- fn
1634− (div [%f & --0 1] a)
1635−```
1636−
1637−#### Examples
1638−
1639−```
1640− > (inv:fl [%f s=%.y e=--0 a=10])
1641− [%f s=%.y e=-116 a=8.307.674.973.655.724.205.648.794.126.752.154]
1642− > (drg:fl [%f s=%.y e=-116 a=8.307.674.973.655.724.205.648.794.126.752.154])
1643− [%d s=%.y e=-1 a=1]
1644−
1645− > (inv:fl [%f s=%.y e=--1 a=10])
1646− [%f s=%.y e=-117 a=8.307.674.973.655.724.205.648.794.126.752.154]
1647− > (drg:fl [%f s=%.y e=-117 a=8.307.674.973.655.724.205.648.794.126.752.154])
1648− [%d s=%.y e=-2 a=5]
1649−
1650− > (inv:fl [%f s=%.y e=--2 a=10])
1651− [%f s=%.y e=-118 a=8.307.674.973.655.724.205.648.794.126.752.154]
1652− > (drg:fl [%f s=%.y e=-118 a=8.307.674.973.655.724.205.648.794.126.752.154])
1653− [%d s=%.y e=-3 a=25]
1654−```
1655−
1656−---
1657−### `++sun:fl`
1658−
1659−Signed integer to float
1660−
1661−Produces `a` in floating-point representation.
1662−
1663−#### Accepts
1664−
1665−`a` is an unsigned integer.
1666−
1667−#### Produces
1668−
1669−An `fn`.
1670−
1671−#### Source
1672−
1673−```hoon
1674− ++ sun
1675− |= [a=@u] ^- fn
1676− (rou [%f & --0 a])
1677−```
1678−
1679−#### Examples
1680−
1681−```
1682− > (sun:fl 0)
1683− [%f s=%.y e=--0 a=0]
1684−
1685− > (sun:fl 5.048.729)
1686− [%f s=%.y e=-90 a=6.250.023.776.601.238.669.911.180.544.311.296]
1687−
1688− > (sun:fl -100)
1689− ! exit
1690−```
1691−
1692−---
1693−### `++san:fl`
1694−
1695−Signed integer to float
1696−
1697−Produces the floating-point representation of `a`, an unsigned integer.
1698−
1699−#### Accepts
1700−
1701−`a` is an unsigned integer.
1702−
1703−#### Produces
1704−
1705−An `fn`.
1706−
1707−#### Source
1708−
1709−```hoon
1710− ++ san
1711− |= [a=@s] ^- fn
1712− =+ b=(old:si a)
1713− (rou [%f -.b --0 +.b])
1714−```
1715−
1716−#### Examples
1717−
1718−```
1719− > (san:fl --100)
1720− [%f s=%.y e=-106 a=8.112.963.841.460.668.169.578.900.514.406.400]
1721−
1722− > (san:fl -100)
1723− [%f s=%.n e=-106 a=8.112.963.841.460.668.169.578.900.514.406.400]
1724−```
1725−
1726−---
1727−### `++lth:fl`
1728−
1729−Less than
1730−
1731−Tests if `a` is less than `b`. Returns `~` in the event of `a` or `b` being a
1732−NaN (`[%n ~]`).
1733−
1734−#### Accepts
1735−
1736−`a` is an `fn`.
1737−
1738−`b` is an `fn`.
1739−
1740−#### Produces
1741−
1742−A `unit` of `flag`.
1743−
1744−#### Source
1745−
1746−```hoon
1747− ++ lth
1748− |= [a=fn b=fn] ^- (unit ?)
1749− ?: |(?=([$n *] a) ?=([$n *] b)) ~ :- ~
1750− ?: =(a b) |
1751− ?: ?=([$i *] a) !s.a ?: ?=([$i *] b) s.b
1752− ?: |(=(a.a 0) =(a.b 0))
1753− ?: &(=(a.a 0) =(a.b 0)) |
1754− ?: =(a.a 0) s.b !s.a
1755− ?: !=(s.a s.b) s.b
1756− ?: s.a (^lth +>.a +>.b) (^lth +>.b +>.a)
1757−```
1758−
1759−#### Examples
1760−
1761−```
1762− > (lth:fl (sun:fl 116) (sun:fl 4.820))
1763− [~ u=%.y]
1764−
1765− > (lth:fl (sun:fl 218.116) (sun:fl 4.820))
1766− [~ u=%.n]
1767−
1768− > (lth:fl (sun:fl 218.116) [%n ~])
1769− ~
1770−```
1771−
1772−---
1773−### `++lte:fl`
1774−
1775−Less than or equal
1776−
1777−Tests whether `a` is less than or equal to `b`. Returns `~` in the event of `a`
1778−or `b` being a NaN (`[%n ~]`).
1779−
1780−#### Accepts
1781−
1782−`a` is an `fn`.
1783−
1784−`b` is an `fn`.
1785−
1786−#### Produces
1787−
1788−A `unit` of `flag`.
1789−
1790−#### Source
1791−
1792−```hoon
1793− ++ lte
1794− |= [a=fn b=fn] ^- (unit ?)
1795− %+ bind (lth b a) |= a=? !a
1796−```
1797−
1798−#### Examples
1799−
1800−```
1801− > (lte:fl (sun:fl 102) [%f %.y -5 973.655.724])
1802− [~ u=%.y]
1803−
1804− > (lte:fl (sun:fl 102) [%f %.y -24 973.655.724])
1805− [~ u=%.n]
1806−
1807− > (lte:fl [%f %.y --2 25] (sun:fl 100))
1808− [~ u=%.y]
1809−
1810− > (lte:fl [%f %.y --2 25] [%f %.y --3 2])
1811− [~ u=%.n]
1812−
1813− > (lte:fl [%f %.y --2 25] [%n ~])
1814− ~
1815−```
1816−
1817−---
1818−### `++equ:fl`
1819−
1820−Equals
1821−
1822−Tests if `a` is equal to `b`. Returns `~` in the event of `a` or `b` being a NaN
1823−(`[%n ~]`).
1824−
1825−#### Accepts
1826−
1827−`a` is an `fn`.
1828−
1829−`b` is an `fn`.
1830−
1831−#### Produces
1832−
1833−An `unit` of `flag`.
1834−
1835−#### Source
1836−
1837−```hoon
1838− ++ equ
1839− |= [a=fn b=fn] ^- (unit ?)
1840− ?: |(?=([$n *] a) ?=([$n *] b)) ~ :- ~
1841− ?: =(a b) &
1842− ?: |(?=([$i *] a) ?=([$i *] b)) |
1843− ?: |(=(a.a 0) =(a.b 0))
1844− ?: &(=(a.a 0) =(a.b 0)) & |
1845− ?: |(=(e.a e.b) !=(s.a s.b)) |
1846− (^equ +>.a +>.b)
1847−```
1848−
1849−#### Examples
1850−
1851−```
1852− > (equ:fl [%f %.y --2 25] (sun:fl 100))
1853− [~ u=%.y]
1854−
1855− > (equ:fl [%f %.y --2 25] (sun:fl 101))
1856− [~ u=%.n]
1857−```
1858−
1859−---
1860−### `++gte:fl`
1861−
1862−Greater or equal than
1863−
1864−Tests whether `a` is greater than or equal to `b`. Returns `~` in the event of
1865−`a` or `b` being a NaN (`[%n ~]`).
1866−
1867−#### Accepts
1868−
1869−`a` is an `fn`.
1870−
1871−`b` is an `fn`.
1872−
1873−#### Produces
1874−
1875−An `unit` of `flag`.
1876−
1877−#### Source
1878−
1879−```hoon
1880− ++ gte
1881− |= [a=fn b=fn] ^- (unit ?) (lte b a)
1882−```
1883−
1884−#### Examples
1885−
1886−```
1887− > (gte:fl [%f %.y --2 25] (sun:fl 100))
1888− [~ u=%.y]
1889−
1890− > (gth:fl [%f %.y --6 73.989] [%f %.y --5 919.599])
1891− [~ u=%.n]
1892−
1893− > (gth:fl [%f %.y --6 73.989] [%n ~])
1894− ~
1895−```
1896−
1897−---
1898−### `++gth:fl`
1899−
1900−Greater than
1901−
1902−Tests whether `a` is greater than `b`. Returns `~` in the event of `a` or `b`
1903−being a NaN (`[%n ~]`).
1904−
1905−#### Accepts
1906−
1907−`a` is an `fn`.
1908−
1909−`b` is an `fn`.
1910−
1911−#### Produces
1912−
1913−An `unit` of `flag`.
1914−
1915−#### Source
1916−
1917−```hoon
1918− ++ gth
1919− |= [a=fn b=fn] ^- (unit ?) (lth b a)
1920−```
1921−
1922−#### Examples
1923−
1924−```
1925− > (gth:fl [%f %.y --2 25] (sun:fl 100))
1926− [~ u=%.n]
1927−
1928− > (gth:fl [%f %.y --6 73.989] [%f %.y --5 119.599])
1929− [~ u=%.y]
1930−```
1931−
1932−---
1933−### `++drg:fl`
1934−
1935−Float to decimal
1936−
1937−Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
1938−accurate results for rounded floats.
1939−
1940−#### Accepts
1941−
1942−`a` is an `fn`.
1943−
1944−#### Produces
1945−
1946−A `dn`.
1947−
1948−#### Source
1949−
1950−```hoon
1951− ++ drg
1952− |= [a=fn] ^- dn
1953− ?: ?=([$n *] a) [%n ~]
1954− ?: ?=([$i *] a) [%i s.a]
1955− ?~ a.a [%d s.a --0 0]
1956− [%d s.a (^drg +>.a)]
1957−```
1958−
1959−#### Examples
1960−
1961−```
1962− > (drg:fl [%f | --6 73.989])
1963− [%d s=%.n e=--0 a=4.735.296]
1964−```
1965−
1966−---
1967−### `++grd:fl`
1968−
1969−Decimal to float
1970−
1971−Converts decimal `a` to `fn`.
1972−
1973−#### Accepts
1974−
1975−`a` is a `dn`.
1976−
1977−#### Produces
1978−
1979−An `fn`.
1980−
1981−#### Source
1982−
1983−```hoon
1984− ++ grd
1985− |= [a=dn] ^- fn
1986− ?: ?=([$n *] a) [%n ~]
1987− ?: ?=([$i *] a) [%i s.a]
1988− => .(r %n)
1989− =+ q=(abs:si e.a)
1990− ?: (syn:si e.a)
1991− (mul [%f s.a --0 a.a] [%f & e.a (pow 5 q)])
1992− (div [%f s.a --0 a.a] [%f & (sun:si q) (pow 5 q)])
1993−```
1994−
1995−#### Examples
1996−
1997−```
1998− > (grd:fl [%d s=%.n e=--0 a=73.989])
1999− [%f s=%.n e=-96 a=5.862.012.516.267.904.074.208.723.341.410.304]
2000−
2001− > (grd:fl [%d s=%.n e=--0 a=100])
2002− [%f s=%.n e=-106 a=8.112.963.841.460.668.169.578.900.514.406.400]
2003−```
2004−
2005−---
2006−### `++toi:fl`
2007−
2008−Round to signed integer
2009−
2010−Rounds `a` to the nearest signed integer.
2011−
2012−#### Accepts
2013−
2014−`a` is an `fn`.
2015−
2016−#### Produces
2017−
2018−A `unit` of @s.
2019−
2020−#### Source
2021−
2022−```hoon
2023− ++ toi
2024− |= [a=fn] ^- (unit @s)
2025− =+ b=(toj a)
2026− ?. ?=([$f *] b) ~ :- ~
2027− =+ c=(^^mul (bex (abs:si e.b)) a.b)
2028− (new:si s.b c)
2029−```
2030−
2031−#### Examples
2032−
2033−```
2034− > (toi:fl [%f s=%.y e=-78 a=8.112.963.841.460.668.169.578.900.514.406.400])
2035− [~ u=--26.843.545.600]
2036−```
2037−
2038−---
2039−### `++toj:fl`
2040−
2041−Round to integer fn
2042−
2043−Rounds `a` to the nearest decimal integer.
2044−
2045−#### Accepts
2046−
2047−`a` is an `fn`.
2048−
2049−#### Produces
2050−
2051−A `unit` of @s.
2052−
2053−#### Source
2054−
2055−```hoon
2056− ++ toj
2057− |= [a=fn] ^- fn
2058− ?. ?=([$f *] a) a
2059− ?~ a.a [%f s.a zer]
2060− ?: s.a (^toj +>.a)
2061− =.(r swr (fli (^toj +>.a)))
2062− --
2063−```
2064−
2065−#### Examples
2066−
2067−```
2068− > (toj:fl [%f s=%.y e=-78 a=8.112.963.841.460.668.169.578.900.514.406.400])
2069− [%f s=%.y e=--0 a=26.843.545.600]
2070−
2071− > (toj:fl [%f s=%.y e=-78 a=8.112.963.841.460.668.169.578.900.514])
2072− [%f s=%.y e=--0 a=26.844]
2073−
2074− > (toj:fl [%f s=%.y e=-78 a=8.112.963.841.460])
2075− [%f s=%.y e=--0 a=0]
2076−
2077− > (toj:fl [%f s=%.y e=-9 a=9.002])
2078− [%f s=%.y e=--0 a=16]
2079−```
2080−
2081−---
2082−### `++ff`
2083−
2084−IEEE-754 Formatting
2085−
2086−Container core for IEEE-754 formatting operations.
2087−
2088−- `w` is width: The number of bits in the exponent field.
2089−- `p` is precision: The number of bits in the significand field.
2090−- `w` is bias: Added to exponent when storing.
2091−- `r` is rounding mode: Possible modes are nearest (`$n`), up (`$u`),
2092− down (`$d`), to zero (`$z`), and away from zero (`$a`). Default value is `%a`.
2093−
2094−#### Source
2095−
2096−```hoon
2097− ++ ff
2098− |_ [[w=@u p=@u b=@s] r=$?($n $u $d $z $a)]
2099−```
2100−
2101−#### Examples
2102−
2103−```
2104− > =ffcore ~(. ff [8 8 0] %n)
2105− > ffcore
2106− <24.ltg {{{@ud @ud @ud} r/$n} <54.tyv 119.wim 31.ohr 1.jmk $143>}>
2107− >
2108−```
2109−
2110−---
2111−#### Discussion
2112−
2113−`++ff` has no use outside of the functionality provided to other cores: `++rd`,
2114−`++rs`, `++rq`, and `++rh`. It's not intended to be used directly; it's just
2115−meant to power those cores.
2116−
2117−---
2118−### `++sb:ff`
2119−
2120−Sign bit
2121−
2122−Produces the sign bit of `++ff`.
2123−
2124−#### Source
2125−
2126−```hoon
2127− ++ sb (bex (^add w p))
2128−```
2129−
2130−#### Examples
2131−
2132−```
2133− > sb:ff
2134− 1
2135−```
2136−
2137−---
2138−### `++me:ff`
2139−
2140−Minimum exponent
2141−
2142−Produces the minimum possible exponent of `ff`.
2143−
2144−#### Source
2145−
2146−```hoon
2147− ++ me (dif:si (dif:si --1 b) (sun:si p))
2148−```
2149−
2150−#### Examples
2151−
2152−```
2153− > me:ff
2154− --1
2155−```
2156−
2157−---
2158−### `++pa:ff`
2159−
2160−Initialize `fl`
2161−
2162−Instantiates the core `fl`, giving values to its samples based on the
2163−configuration of the `ff` core.
2164−
2165−#### Source
2166−
2167−```hoon
2168− ++ pa
2169− %*(. fl p +(p), v me, w (^sub (bex w) 3), d %d, r r)
2170−```
2171−
2172−#### Examples
2173−
2174−```
2175− > ~(pa ff [11 52 --1.023] %n)
2176− < 23.qzd
2177− 28.btz
2178− { {{p/@ v/@s w/@} r/?($n $u $a $d $z) d/$d}
2179− <54.tyv 119.wim 31.ohr 1.jmk $143>
2180− }
2181− >
2182−```
2183−
2184−#### Discussion
2185−
2186−`++pa` exists exclusively for internal use of `++ff`, and `++ff` exists for
2187−internal use in other cores.
2188−
2189−---
2190−### `++sea:ff`
2191−
2192−`@r` to `fn`
2193−
2194−Converts `a` from `@r` to `fn`.
2195−
2196−#### Accepts
2197−
2198−`a` is a `@r`, an IEEE float.
2199−
2200−#### Produces
2201−
2202−A `unit` of @s.
2203−
2204−#### Source
2205−
2206−```hoon
2207− ++ sea
2208− |= [a=@r] ^- fn
2209− =+ [f=(cut 0 [0 p] a) e=(cut 0 [p w] a)]
2210− =+ s=(sig a)
2211− ?: =(e 0)
2212− ?: =(f 0) [%f s --0 0] [%f s me f]
2213− ?: =(e (fil 0 w 1))
2214− ?: =(f 0) [%i s] [%n ~]
2215− =+ q=:(sum:si (sun:si e) me -1)
2216− =+ r=(^add f (bex p))
2217− [%f s q r]
2218−```
2219−
2220−#### Examples
2221−
2222−```
2223− > (sea:ff `@r`0x8)
2224− [%f s=%.y e=--0 a=0]
2225−```
2226−
2227−---
2228−### `++bit:ff`
2229−
2230−`fn` to `@r`, rounding
2231−
2232−Converts `a` from `fn` to `@r` and applies rounding.
2233−
2234−#### Accepts
2235−
2236−`a` is an `fn`.
2237−
2238−#### Produces
2239−
2240−A `@r`.
2241−
2242−#### Source
2243−
2244−```hoon
2245− ++ bit |= [a=fn] (bif (rou:pa a))
2246−```
2247−
2248−#### Examples
2249−
2250−```
2251− > (bit:ma:rd [%f | -6 202])
2252− 0xc009400000000000
2253−```
2254−
2255−---
2256−### `++bif:ff`
2257−
2258−`fn` to `@r`, no rounding
2259−
2260−Converts `a` from `fn` to `@r`. No rounding is applied.
2261−
2262−#### Accepts
2263−
2264−`a` is a `@r`, an IEEE float.
2265−
2266−#### Produces
2267−
2268−A `flag`.
2269−
2270−#### Source
2271−
2272−```hoon
2273− ++ bif
2274− |= [a=fn] ^- @r
2275− ?: ?=([$i *] a)
2276− =+ q=(lsh 0 p (fil 0 w 1))
2277− ?: s.a q (^add q sb)
2278− ?: ?=([$n *] a) (lsh 0 (dec p) (fil 0 +(w) 1))
2279− ?~ a.a ?: s.a `@r`0 sb
2280− =+ ma=(met 0 a.a)
2281− ?. =(ma +(p))
2282− ?> =(e.a me)
2283− ?> (^lth ma +(p))
2284− ?: s.a `@r`a.a (^add a.a sb)
2285− =+ q=(sum:si (dif:si e.a me) --1)
2286− =+ r=(^add (lsh 0 p (abs:si q)) (end 0 p a.a))
2287− ?: s.a r (^add r sb)
2288−```
2289−
2290−#### Examples
2291−
2292−```
2293− > (bif:ma:rd *fn)
2294− 0x7ff8000000000000
2295−```
2296−
2297−---
2298−### `++sig:ff`
2299−
2300−Get sign
2301−
2302−Produces the sign of `a`.
2303−
2304−#### Accepts
2305−
2306−`a` is a `@r`, an IEEE float.
2307−
2308−#### Produces
2309−
2310−A `flag`.
2311−
2312−#### Source
2313−
2314−```hoon
2315− ++ sig
2316− |= [a=@r] ^- ?
2317− =(0 (cut 0 [(^add p w) 1] a))
2318−```
2319−
2320−#### Examples
2321−
2322−```
2323− > (sig:ff `@r`5)
2324− %.n
2325−```
2326−
2327−---
2328−### `++exp:ff`
2329−
2330−Get exponent
2331−
2332−Produces the exponent of `a`.
2333−
2334−#### Accepts
2335−
2336−`a` is a `@r`, an IEEE float.
2337−
2338−#### Produces
2339−
2340−A signed integer.
2341−
2342−#### Source
2343−
2344−```hoon
2345− ++ exp
2346− |= [a=@r] ^- @s
2347− (dif:si (sun:si (cut 0 [p w] a)) b)
2348−```
2349−
2350−#### Examples
2351−
2352−```
2353− > (exp:ff `@r`5)
2354− --0
2355−```
2356−
2357−---
2358−### `++add:ff`
2359−
2360−Add
2361−
2362−Produces the sum of `a` plus `b`.
2363−
2364−#### Accepts
2365−
2366−`a` is a `@r`, an IEEE float.
2367−
2368−`b` is a `@r`, an IEEE float.
2369−
2370−#### Produces
2371−
2372−A `@r`, an IEEE float.
2373−
2374−#### Source
2375−
2376−```hoon
2377− ++ add
2378− |= [a=@r b=@r]
2379− (bif (add:pa (sea a) (sea b)))
2380−```
2381−
2382−#### Examples
2383−
2384−```
2385− > (add:ma:rd `@r`5 `@r`11)
2386− 0x10
2387−```
2388−
2389−---
2390−### `++sub:ff`
2391−
2392−Sub
2393−
2394−Produces the sum of `a` plus `b`.
2395−
2396−#### Accepts
2397−
2398−`a` is a `@r`, an IEEE float.
2399−
2400−`b` is a `@r`, an IEEE float.
2401−
2402−#### Produces
2403−
2404−A `@r`, an IEEE float.
2405−
2406−#### Source
2407−
2408−```hoon
2409− ++ sub
2410− |= [a=@r b=@r]
2411− (bif (sub:pa (sea a) (sea b)))
2412−```
2413−
2414−#### Examples
2415−
2416−```
2417− > (sub:ma:rd `@r`5 `@r`11)
2418− 0x8000000000000006
2419−```
2420−
2421−---
2422−### `++mul:ff`
2423−
2424−Multiply
2425−
2426−Produces the product of `a` multiplied by `b`.
2427−
2428−#### Accepts
2429−
2430−`a` is a `@r`, an IEEE float.
2431−
2432−`b` is a `@r`, an IEEE float.
2433−
2434−#### Produces
2435−
2436−A `@r`, an IEEE float.
2437−
2438−#### Multiply
2439−
2440−```hoon
2441− ++ mul
2442− |= [a=@r b=@r]
2443− (bif (mul:pa (sea a) (sea b)))
2444−```
2445−
2446−#### Examples
2447−
2448−```
2449− > (mul:ma:rd `@r`11 `@r`2)
2450− 0x0
2451−```
2452−
2453−---
2454−### `++div:ff`
2455−
2456−Divide
2457−
2458−Produces the quotient of `a` divided by `b`.
2459−
2460−#### Accepts
2461−
2462−`a` is a `@r`, an IEEE float.
2463−
2464−`b` is a `@r`, an IEEE float.
2465−
2466−#### Produces
2467−
2468−A `@r`, an IEEE float.
2469−
2470−#### Source
2471−
2472−```hoon
2473− ++ div
2474− |= [a=@r b=@r]
2475− (bif (div:pa (sea a) (sea b)))
2476−```
2477−
2478−#### Examples
2479−
2480−```
2481− > (div:ma:rd `@r`175 `@r`26)
2482− 0x401aec4ec4ec4ec4
2483−```
2484−
2485−---
2486−### `++fma:ff`
2487−
2488−Fused multiply-add
2489−
2490−Produces the sum of `c` plus the product of `a` multiplied by `b`;
2491−`(a * b) + c`.
2492−
2493−#### Accepts
2494−
2495−`a` is a `@r`, an IEEE float.
2496−
2497−`b` is a `@r`, an IEEE float.
2498−
2499−`c` is a `@r`, an IEEE float.
2500−
2501−#### Produces
2502−
2503−A `@r`, an IEEE float.
2504−
2505−#### Source
2506−
2507−```hoon
2508− ++ fma
2509− |= [a=@r b=@r c=@r]
2510− (bif (fma:pa (sea a) (sea b) (sea c)))
2511−```
2512−
2513−#### Examples
2514−
2515−```
2516− > (fma:ma:rd `@r`175 `@r`26 `@r`100)
2517− 0x64
2518−```
2519−
2520−---
2521−### `++sqt:ff`
2522−
2523−Square root
2524−
2525−Produces the square root of `a`.
2526−
2527−#### Accepts
2528−
2529−`a` is a `@r`, an IEEE float.
2530−
2531−#### Produces
2532−
2533−A `@r`, an IEEE float.
2534−
2535−#### Source
2536−
2537−```hoon
2538− ++ sqt
2539− |= [a=@r]
2540− (bif (sqt:pa (sea a)))
2541−```
2542−
2543−#### Examples
2544−
2545−```
2546− > (sqt:ma:rd `@r`175)
2547− 0x1e9a751f9447b724
2548−```
2549−
2550−---
2551−### `++lth:ff`
2552−
2553−Less than
2554−
2555−Tests whether `a` is less than `b`.
2556−
2557−#### Accepts
2558−
2559−`a` is a `@r`, an IEEE float.
2560−
2561−`b` is a `@r`, an IEEE float.
2562−
2563−#### Produces
2564−
2565−A `flag`.
2566−
2567−#### Source
2568−
2569−```hoon
2570− ++ lth
2571− |= [a=@r b=@r] (fall (lth:pa (sea a) (sea b)) |)
2572−```
2573−
2574−#### Examples
2575−
2576−```
2577− > (lth:ma:rd `@rd`1 `@rd`2)
2578− %.y
2579−
2580− > (lth:ma:rd `@rd`10 `@rd`2)
2581− %.n
2582−```
2583−
2584−---
2585−### `++lte:ff`
2586−
2587−Less than or equal to
2588−
2589−Tests whether `a` is less than or equal to `b`.
2590−
2591−#### Accepts
2592−
2593−`a` is a `@r`, an IEEE float.
2594−
2595−`b` is a `@r`, an IEEE float.
2596−
2597−#### Produces
2598−
2599−A `flag`.
2600−
2601−#### Source
2602−
2603−```hoon
2604− ++ lte
2605− |= [a=@r b=@r] (fall (lte:pa (sea a) (sea b)) |)
2606−```
2607−
2608−#### Examples
2609−
2610−```
2611− > (lte:ma:rd `@rd`10 `@rd`2)
2612− %.n
2613−
2614− > (lte:ma:rd `@rd`10 `@rd`10)
2615− %.y
2616−```
2617−
2618−---
2619−### `++equ:ff`
2620−
2621−Equals
2622−
2623−Tests whether `a` is equal to `b`.
2624−
2625−#### Accepts
2626−
2627−`a` is a `@r`, an IEEE float.
2628−
2629−`b` is a `@r`, an IEEE float.
2630−
2631−#### Produces
2632−
2633−A `flag`.
2634−
2635−#### Source
2636−
2637−```hoon
2638− ++ equ
2639− |= [a=@r b=@r] (fall (equ:pa (sea a) (sea b)) |)
2640−```
2641−
2642−#### Examples
2643−
2644−```
2645− > (equ:ma:rd `@rd`10 `@rd`2)
2646− %.n
2647−
2648− > (equ:ma:rd `@rd`10 `@rd`10)
2649− %.y
2650−```
2651−
2652−---
2653−### `++gte:ff`
2654−
2655−Greater or equal than
2656−
2657−Tests whether `a` is greater than or equal to `b`.
2658−
2659−#### Accepts
2660−
2661−`a` is a `@r`, an IEEE float.
2662−
2663−`b` is a `@r`, an IEEE float.
2664−
2665−#### Produces
2666−
2667−A `flag`.
2668−
2669−#### Source
2670−
2671−```hoon
2672− ++ gte
2673− |= [a=@r b=@r] (fall (gte:pa (sea a) (sea b)) |)
2674−```
2675−
2676−#### Examples
2677−
2678−```
2679− > (gte:ma:rd `@rd`10 `@rd`10)
2680− %.y
2681−
2682− > (gte:ma:rd `@rd`10 `@rd`11)
2683− %.n
2684−```
2685−
2686−---
2687−### `++gth:ff`
2688−
2689−Greater than
2690−
2691−Tests whether `a` is greater than or equal to `b`.
2692−
2693−#### Accepts
2694−
2695−`a` is a `@r`, an IEEE float.
2696−
2697−`b` is a `@r`, an IEEE float.
2698−
2699−#### Produces
2700−
2701−A `flag`.
2702−
2703−#### Source
2704−
2705−```hoon
2706− ++ gth
2707− |= [a=@r b=@r] (fall (gth:pa (sea a) (sea b)) |)
2708−```
2709−
2710−#### Examples
2711−
2712−```
2713− > (gth:ma:rd `@rd`10 `@rd`10)
2714− %.n
2715−
2716− > (gth:ma:rd `@rd`10 `@rd`9)
2717− %.y
2718−```
2719−
2720−---
2721−### `++sun:ff`
2722−
2723−Unsigned integer to `@r`
2724−
2725−Converts `a` from an unsigned integer (`@u`) to `@r`.
2726−
2727−#### Accepts
2728−
2729−`a` is `@u`, unsigned integer.
2730−
2731−#### Produces
2732−
2733−A `@r`, an IEEE float.
2734−
2735−#### Source
2736−
2737−```hoon
2738− ++ sun
2739− |= [a=@u] (bit [%f & --0 a])
2740−```
2741−
2742−#### Examples
2743−
2744−```
2745− > (sun:ma:rd 658.149.282)
2746− 0x41c39d47d1000000
2747−```
2748−
2749−---
2750−### `++san:ff`
2751−
2752−Signed integer to `@r`
2753−
2754−Converts `a` from a signed integer to `@r`.
2755−
2756−#### Accepts
2757−
2758−`a` is `@s`, an unsigned integer
2759−
2760−#### Produces
2761−
2762−A `@r`, an IEEE float.
2763−
2764−#### Source
2765−
2766−```hoon
2767− ++ san
2768− |= [a=@s] (bit [%f (syn:si a) --0 (abs:si a)])
2769−```
2770−
2771−#### Examples
2772−
2773−```
2774− > (san:ma:rd --10)
2775− 0x4024000000000000
2776−```
2777−
2778−---
2779−### `++toi:ff`
2780−
2781−Round to integer
2782−
2783−Rounds `a` to the nearest signed integer.
2784−
2785−#### Accepts
2786−
2787−`a` is a `@r`, an IEEE float.
2788−
2789−#### Produces
2790−
2791−A `flag` of `@s`.
2792−
2793−#### Source
2794−
2795−```hoon
2796− ++ toi
2797− |= [a=@r] (toi:pa (sea a))
2798−```
2799−
2800−#### Examples
2801−
2802−```
2803− > (toi:ma:rd `@r`0x4af)
2804− [~ u=--0]
2805−```
2806−
2807−---
2808−### `++drg:ff`
2809−
2810−`@r` to decimal float
2811−
2812−Converts `a` from `@r` to `dn` using the Dragon4 algorithm.
2813−
2814−#### Accepts
2815−
2816−`a` is a `@r`, an IEEE float.
2817−
2818−#### Produces
2819−
2820−A `dn`.
2821−
2822−#### Source
2823−
2824−```hoon
2825− ++ drg
2826− |= [a=@r] (drg:pa (sea a))
2827−```
2828−
2829−#### Examples
2830−
2831−```
2832− > (drg:ma:rd `@r`0x41c0)
2833− [%d s=%.y e=-323 a=8.316]
2834−
2835− > (drg:ma:rd (sun:ma:rd 658.149.282))
2836− [%d s=%.y e=--0 a=658.149.282]
2837−```
2838−
2839−---
2840−### `++grd:ff`
2841−
2842−Decimal float to `@r`
2843−
2844−Converts `a` from `dn` to `@r`.
2845−
2846−#### Accepts
2847−
2848−`a` is a `dn`.
2849−
2850−#### Produces
2851−
2852−A `@r`, an IEEE float.
2853−
2854−#### Source
2855−
2856−```hoon
2857− ++ grd
2858− |= [a=dn] (bif (grd:pa a))
2859− --
2860−```
2861−
2862−#### Examples
2863−
2864−```
2865− > (grd:ma:rd [%d s=%.y e=--0 a=658.149.282])
2866− 0x41c39d47d1000000
2867−```
2868−
2869−---
2870−### `++rlyd`
2871−
2872−Prep `@rd` for print
2873−
2874−Converts `a` from a double-precision binary float to decimal64.
2875−
2876−#### Accepts
2877−
2878−`a` is a `@rd`, a double-precision float.
2879−
2880−#### Produces
2881−
2882−A `dn`.
2883−
2884−#### Source
2885−
2886−```hoon
2887− ++ rlyd |= a=@rd ^- dn (drg:rd a)
2888−```
2889−
2890−#### Examples
2891−
2892−```
2893− > (rlyd .~2.4703e-320)
2894− [%d s=%.y e=-324 a=24.703]
2895−```
2896−
2897−---
2898−### `++rlys`
2899−
2900−Prep @rs for print
2901−
2902−Converts `a` from a single-precision binary float to decimal32.
2903−
2904−#### Accepts
2905−
2906−`a` is a `@rs`, a single-precision float.
2907−
2908−#### Produces
2909−
2910−A `dn`.
2911−
2912−#### Source
2913−
2914−```hoon
2915− ++ rlys |= a=@rs ^- dn (drg:rs a)
2916−```
2917−
2918−#### Examples
2919−
2920−```
2921− > (rlys .1.681557e-39)
2922− [%d s=%.y e=-45 a=1.681.557]
2923−```
2924−
2925−---
2926−### `++rlyh`
2927−
2928−Prep `@rh` for print
2929−
2930−Converts `a` from a half-precision binary float to decimal16.
2931−
2932−#### Accepts
2933−
2934−`a` is a `@rh`, a half-precision float.
2935−
2936−#### Produces
2937−
2938−A `dn`.
2939−
2940−#### Source
2941−
2942−```hoon
2943− ++ rlyh |= a=@rh ^- dn (drg:rh a)
2944−```
2945−
2946−#### Examples
2947−
2948−```
2949− > (rlyh .~~3e1)
2950− [%d s=%.y e=--1 a=3]
2951−```
2952−
2953−---
2954−### `++rlyq`
2955−
2956−Prep `@rq` for print
2957−
2958−Converts `a` from a quad-precision binary float to decimal128.
2959−
2960−#### Accepts
2961−
2962−`a` is a `@rq`, a quad-precision float.
2963−
2964−#### Produces
2965−
2966−A `dn`.
2967−
2968−#### Source
2969−
2970−```hoon
2971− ++ rlyq |= a=@rq ^- dn (drg:rq a)
2972−```
2973−
2974−#### Examples
2975−
2976−```
2977− > (rlyq .~~~2.2628017865927756787440310766086816e-4343)
2978− [%d s=%.y e=-4.377 a=22.628.017.865.927.756.787.440.310.766.086.816]
2979−```
2980−
2981−---
2982−### `++ryld`
2983−
2984−Finish parsing `@rd`
2985−
2986−Converts `a` from a decimal float to a double-precision binary float.
2987−
2988−#### Accepts
2989−
2990−`a` is a `dn`.
2991−
2992−#### Produces
2993−
2994−A a `@rd`, a double-precision float.
2995−
2996−#### Source
2997−
2998−```hoon
2999− ++ ryld |= a=dn ^- @rd (grd:rd a)
3000−```
3001−
3002−#### Examples
3003−
3004−```
3005− > (ryld [%d s=%.y e=-324 a=24.703])
3006− .~2.4703e-320
3007−```
3008−
3009−---
3010−### `++ryls`
3011−
3012−Finish parsing `@rs`
3013−
3014−Converts `a` from a decimal float to a single-precision binary float.
3015−
3016−#### Accepts
3017−
3018−`a` is a `dn`.
3019−
3020−#### Produces
3021−
3022−A a `@rs`, a single-precision float.
3023−
3024−#### Source
3025−
3026−```hoon
3027− ++ ryls |= a=dn ^- @rs (grd:rs a)
3028−```
3029−
3030−#### Examples
3031−
3032−```
3033− > (ryls [%d s=%.y e=-324 a=24.703])
3034− .0
3035−
3036− > (ryls [%d s=%.y e=-32 a=24.703])
3037− .2.4703e-28
3038−```
3039−
3040−---
3041−### `++rylh`
3042−
3043−Finish parsing `@rh`
3044−
3045−Converts `a` from a decimal float to a half-precision binary float.
3046−
3047−#### Accepts
3048−
3049−`a` is a `dn`.
3050−
3051−#### Produces
3052−
3053−A a `@rh`, a half-precision float.
3054−
3055−#### Source
3056−
3057−```hoon
3058− ++ rylh |= a=dn ^- @rh (grd:rh a)
3059−```
3060−
3061−#### Examples
3062−
3063−```
3064− > (rylh [%d s=%.y e=--1 a=703])
3065− .~~7.032e3
3066−
3067− > (rylh [%d s=%.y e=--3 a=56])
3068− .~~5.6e4
3069−
3070− > (rylh [%d s=%.y e=--4 a=56])
3071− .~~inf
3072−```
3073−
3074−---
3075−### `++rylq`
3076−
3077−Finish parsing `@rq`
3078−
3079−Converts `a` from a decimal float to a quad-precision binary float.
3080−
3081−#### Accepts
3082−
3083−`a` is a `dn`.
3084−
3085−#### Produces
3086−
3087−A a `@rq`, a quad-precision float.
3088−
3089−#### Source
3090−
3091−```hoon
3092− ++ rylq |= a=dn ^- @rq (grd:rq a)
3093−```
3094−
3095−#### Examples
3096−
3097−```
3098− > (rylq [%d s=%.y e=-324 a=24.703])
3099− .~~~2.4703e-320
3100−```
3101−
3102−---
3103−### `++rd`
3104−
3105−Double-precision fp
3106−
3107−A container core for operations related to double-precision binary floats.
3108−
3109−`++rd` has four rounding modes: round to nearest (`$n`), round up (`$u`), round
3110−down (`$d`), and round to zero (`$z`).
3111−
3112−#### Source
3113−
3114−```hoon
3115− ++ rd
3116− ^?
3117− ~% %rd +> ~
3118− |_ r=$?($n $u $d $z)
3119−```
3120−
3121−---
3122−### `++ma:rd`
3123−
3124−Initialize `ff`
3125−
3126−Instantiates the core `ff`, giving values to its samples based on the
3127−configuration of the `rd` core.
3128−
3129−#### Source
3130−
3131−```hoon
3132− ++ ma
3133− %*(. ff w 11, p 52, b --1.023, r r)
3134−```
3135−
3136−#### Examples
3137−
3138−```
3139− > ~(ma rd %n)
3140− < 24.ltg
3141− {{{w/@ud p/@ud b/@sd} r/?($n $u $d $z)} <54.tyv 119.wim 31.ohr 1.jmk $143>}
3142− >
3143−```
3144−
3145−---
3146−### `++sea:rd`
3147−
3148−`@rd` to `fn`
3149−
3150−Converts `a` from a double-precision binary float to `fn`.
3151−
3152−```hoon
3153− ++ sea :: @rd to fn
3154− |= [a=@rd] (sea:ma a)
3155−```
3156−
3157−#### Examples
3158−
3159−```
3160− > (sea:rd .~4.94066e-319)
3161− [%f s=%.y e=-1.074 a=100.000]
3162−```
3163−
3164−---
3165−### `++bit:rd`
3166−
3167−`fn` to `@rd`
3168−
3169−Converts `a` from `fn` to a double-precision binary float.
3170−
3171−#### Accepts
3172−
3173−`a` is an `fn`.
3174−
3175−#### Produces
3176−
3177−A `@rd`, a double-precision float.
3178−
3179−#### Source
3180−
3181−```hoon
3182− ++ bit
3183− |= [a=fn] ^- @rd (bit:ma a)
3184−```
3185−
3186−#### Examples
3187−
3188−```
3189− > (bit:rd [%f s=%.y e=-1.074 a=100.000])
3190− .~4.94066e-319
3191−```
3192−
3193−---
3194−### `++add:rd`
3195−
3196−Add
3197−
3198−Produces the sum of `a` plus `b`.
3199−
3200−#### Accepts
3201−
3202−`a` is a `@rd`, a double-precision float.
3203−
3204−`b` is a `@rd`, a double-precision float.
3205−
3206−#### Produces
3207−
3208−A `@rd`.
3209−
3210−#### Source
3211−
3212−```hoon
3213− ++ add ~/ %add
3214− |= [a=@rd b=@rd] ^- @rd
3215− ~_ leaf+"rd-fail"
3216− (add:ma a b)
3217−```
3218−
3219−#### Examples
3220−
3221−```
3222− > (add:rd .~3.94066e12 .~9.2846e11)
3223− .~4.86912e12
3224−```
3225−
3226−---
3227−### `++sub:rd`
3228−
3229−Subtract
3230−
3231−Produces the difference of `a` minus `b`.
3232−
3233−#### Accepts
3234−
3235−`a` is a `@rd`, a double-precision float.
3236−
3237−`b` is a `@rd`, a double-precision float.
3238−
3239−#### Produces
3240−
3241−A `@rd`.
3242−
3243−#### Source
3244−
3245−```hoon
3246− ++ sub ~/ %sub
3247− |= [a=@rd b=@rd] ^- @rd
3248− ~_ leaf+"rd-fail"
3249− (sub:ma a b)
3250−```
3251−
3252−#### Examples
3253−
3254−```
3255− > (sub:rd .~7.94069e2 .~1.2846e3)
3256− .~-4.9053099999999995e2
3257−```
3258−
3259−---
3260−### `++mul:rd`
3261−
3262−Multiply
3263−
3264−Produces the product of `a` times `b`.
3265−
3266−#### Accepts
3267−
3268−`a` is a `@rd`, a double-precision float.
3269−
3270−`b` is a `@rd`, a double-precision float.
3271−
3272−#### Produces
3273−
3274−A `@rd`.
3275−
3276−#### Source
3277−
3278−```hoon
3279− ++ mul ~/ %mul
3280− |= [a=@rd b=@rd] ^- @rd
3281− ~_ leaf+"rd-fail"
3282− (mul:ma a b)
3283−```
3284−
3285−#### Examples
3286−
3287−```
3288− > (mul:rd .~7.94069e2 .~1.2246e3)
3289− .~9.724168973999998e5
3290−```
3291−
3292−---
3293−### `++div:rd`
3294−
3295−Divide
3296−
3297−Produces the quotient of `a` divided by `b`.
3298−
3299−#### Accepts
3300−
3301−`a` is a `@rd`, a double-precision float.
3302−
3303−`b` is a `@rd`.
3304−
3305−#### Produces
3306−
3307−A `@rd`.
3308−
3309−#### Source
3310−
3311−```hoon
3312− ++ div ~/ %div
3313− |= [a=@rd b=@rd] ^- @rd
3314− ~_ leaf+"rd-fail"
3315− (div:ma a b)
3316−```
3317−
3318−#### Examples
3319−
3320−```
3321− > (div:rd .~7.94099e2 .~1.2246e3)
3322− .~6.484558223093255e-1
3323−```
3324−
3325−---
3326−### `++fma:rd`
3327−
3328−Fused multiply-add
3329−
3330−Produces the sum of `c` plus the product of `a` multiplied by `b`;
3331−`(a * b) + c`.
3332−
3333−#### Accepts
3334−
3335−`a` is a `@rd`, an IEEE float.
3336−
3337−`b` is a `@rd`.
3338−
3339−`c` is a `@rd`.
3340−
3341−#### Produces
3342−
3343−A `@rd`.
3344−
3345−#### Source
3346−
3347−
3348−#### Source
3349−
3350−```hoon
3351− ++ fma ~/ %fma
3352− |= [a=@rd b=@rd c=@rd] ^- @rd
3353− ~_ leaf+"rd-fail"
3354− (fma:ma a b c)
3355−```
3356−
3357−#### Examples
3358−
3359−```
3360− > (fma:rd .~7.94099e2 .~1.2246e3 .~3.94066e3)
3361− .~9.763942954e5
3362−```
3363−
3364−---
3365−### `++sqt:rd`
3366−
3367−Square root
3368−
3369−Produces the square root of `a`.
3370−
3371−#### Accepts
3372−
3373−`a` is a `@rd`, a double-precision float.
3374−
3375−#### Produces
3376−
3377−A `@rd`.
3378−
3379−#### Source
3380−
3381−```hoon
3382− ++ sqt ~/ %sqt
3383− |= [a=@rd] ^- @rd ~_ leaf+"rd-fail"
3384− (sqt:ma a)
3385−```
3386−
3387−#### Examples
3388−
3389−```
3390− > (sqt:rd .~3.94066e3)
3391− .~6.2774676422901614e1
3392−```
3393−
3394−---
3395−### `++lth:rd`
3396−
3397−Less than
3398−
3399−Test whether `a` is less than `b`.
3400−
3401−#### Accepts
3402−
3403−`a` is a `@rd`, a double-precision float.
3404−
3405−`b` is a `@rd`, a double-precision float.
3406−
3407−#### Produces
3408−
3409−A `@rd`.
3410−
3411−#### Source
3412−
3413−```hoon
3414− ++ lth ~/ %lth
3415− |= [a=@rd b=@rd]
3416− ~_ leaf+"rd-fail"
3417− (lth:ma a b)
3418−```
3419−
3420−#### Examples
3421−
3422−```
3423− > (lth:rd .~7.94099e2 .~1.2246e3)
3424− %.y
3425−
3426− > (lth:rd .~7.94099e2 .~1.2246e2)
3427− %.n
3428−
3429− > (lth:rd .~1.2246e2 .~1.2246e2)
3430− %.n
3431−```
3432−
3433−---
3434−### `++lte:rd`
3435−
3436−Less than or equal
3437−
3438−Test whether `a` is less than or equal to `b`.
3439−
3440−#### Accepts
3441−
3442−`a` is a `@rd`, a double-precision float.
3443−
3444−`b` is a `@rd`, a double-precision float.
3445−
3446−#### Produces
3447−
3448−A `@rd`.
3449−
3450−#### Source
3451−
3452−```hoon
3453− ++ lte ~/ %lte :: less-equals
3454− |= [a=@rd b=@rd]
3455− ~_ leaf+"rd-fail"
3456− (lte:ma a b)
3457−```
3458−
3459−#### Examples
3460−
3461−```
3462− > (lte:rd .~7.94099e2 .~1.2246e3)
3463− %.y
3464−
3465− > (lte:rd .~7.94099e2 .~1.2246e2)
3466− %.n
3467−
3468− > (lte:rd .~1.2246e2 .~1.2246e2)
3469− %.y
3470−```
3471−
3472−---
3473−### `++equ:rd`
3474−
3475−Equals
3476−
3477−Test whether `a` is equal to `b`.
3478−
3479−#### Accepts
3480−
3481−`a` is a `@rd`, a double-precision float.
3482−
3483−`b` is a `@rd`, a double-precision float.
3484−
3485−#### Produces
3486−
3487−A `@rd`.
3488−
3489−#### Source
3490−
3491−```hoon
3492− ++ equ ~/ %equ
3493− |= [a=@rd b=@rd]
3494− ~_ leaf+"rd-fail"
3495− (equ:ma a b)
3496−```
3497−
3498−#### Examples
3499−
3500−```
3501− > (equ:rd .~7.94099e2 .~1.2246e3)
3502− %.n
3503−
3504− > (equ:rd .~7.94099e2 .~1.2246e2)
3505− %.n
3506−
3507− > (equ:rd .~1.2246e2 .~1.2246e2)
3508− %.y
3509−```
3510−
3511−---
3512−### `++gte:rd`
3513−
3514−Greater than or equal
3515−
3516−Test whether `a` is greater than or equal to `b`.
3517−
3518−#### Accepts
3519−
3520−`a` is a `@rd`, a double-precision float.
3521−
3522−`b` is a `@rd`, a double-precision float.
3523−
3524−#### Produces
3525−
3526−A `@rd`.
3527−
3528−#### Source
3529−
3530−```hoon
3531− ++ gte ~/ %gte
3532− |= [a=@rd b=@rd]
3533− ~_ leaf+"rd-fail"
3534− (gte:ma a b)
3535−```
3536−
3537−#### Examples
3538−
3539−```
3540− > (gte:rd .~7.94099e2 .~1.2246e3)
3541− %.n
3542−
3543− > (gte:rd .~7.94099e2 .~1.2246e2)
3544− %.y
3545−
3546− > (gte:rd .~1.2246e2 .~1.2246e2)
3547− %.y
3548−```
3549−
3550−---
3551−### `++gth:rd`
3552−
3553−Greater than
3554−
3555−Test whether `a` is greater `b`.
3556−
3557−#### Accepts
3558−
3559−`a` is a `@rd`, a double-precision float.
3560−
3561−`b` is a `@rd`, a double-precision float.
3562−
3563−#### Produces
3564−
3565−A `@rd`.
3566−
3567−#### Source
3568−
3569−```hoon
3570− ++ gth ~/ %gth
3571− |= [a=@rd b=@rd]
3572− ~_ leaf+"rd-fail"
3573− (gth:ma a b)
3574−```
3575−
3576−#### Examples
3577−
3578−```
3579− > (gth:rd .~7.94099e2 .~1.2246e3)
3580− %.n
3581−
3582− > (gth:rd .~7.94099e2 .~1.2246e2)
3583− %.y
3584−
3585− > (gth:rd .~1.2246e2 .~1.2246e2)
3586− %.n
3587−```
3588−
3589−---
3590−### `++sun:rd`
3591−
3592−Unsigned integer to `@rd`
3593−
3594−Converts an unsigned integer `a` to `@rd`.
3595−
3596−#### Accepts
3597−
3598−`a` is a `@u`, an unsigned integer.
3599−
3600−#### Produces
3601−
3602−A `@rd`.
3603−
3604−#### Source
3605−
3606−```hoon
3607− ++ sun |= [a=@u] ^- @rd (sun:ma a)
3608−```
3609−
3610−#### Examples
3611−
3612−```
3613− > (sun:rd 511)
3614− .~5.11e2
3615−```
3616−
3617−---
3618−### `++san:rd`
3619−
3620−Unsigned integer to `@rd`
3621−
3622−Converts a signed integer `a` to `@rd`.
3623−
3624−#### Accepts
3625−
3626−`a` is a `@s`, a signed integer.
3627−
3628−#### Produces
3629−
3630−A `@rd`.
3631−
3632−#### Source
3633−
3634−```hoon
3635− ++ san |= [a=@s] ^- @rd (san:ma a)
3636−```
3637−
3638−#### Examples
3639−
3640−```
3641− > (san:rd -511)
3642− .~-5.11e2
3643−```
3644−
3645−---
3646−### `++sig:rd`
3647−
3648−Get sign
3649−
3650−Produces the sign of `a`.
3651−
3652−#### Accepts
3653−
3654−`a` is a `@rd`
3655−
3656−#### Produces
3657−
3658−A `flag`.
3659−
3660−#### Source
3661−
3662−```hoon
3663− ++ sig |= [a=@rd] ^- ? (sig:ma a)
3664−```
3665−
3666−#### Examples
3667−
3668−```
3669− > (sig:rd .~1.2246e3)
3670− %.y
3671−```
3672−
3673−---
3674−### `++exp:rd`
3675−
3676−Get exponent
3677−
3678−Produces the exponent of `a`.
3679−
3680−#### Accepts
3681−
3682−`a` is a `@rd`
3683−
3684−#### Produces
3685−
3686−A `@s`.
3687−
3688−#### Source
3689−
3690−```hoon
3691− ++ exp |= [a=@rd] ^- @s (exp:ma a) :: get exponent
3692−```
3693−
3694−#### Examples
3695−
3696−```
3697− > (exp:rd .~1.2246e3)
3698− --10
3699−```
3700−
3701−---
3702−### `++toi:rd`
3703−
3704−Round to integer
3705−
3706−Rounds `a` to the nearest integer.
3707−
3708−#### Accepts
3709−
3710−`a` is a `@rd`
3711−
3712−#### Produces
3713−
3714−A `unit` of `@s`.
3715−
3716−#### Source
3717−
3718−```hoon
3719− ++ toi |= [a=@rd] ^- (unit @s) (toi:ma a)
3720−```
3721−
3722−#### Examples
3723−
3724−```
3725− > (toi:rd .~1.2246e3)
3726− [~ u=--1.224]
3727−```
3728−
3729−---
3730−### `++drg:rd`
3731−
3732−`@rd` to decimal float
3733−
3734−Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
3735−accurate results for rounded floats.
3736−
3737−#### Accepts
3738−
3739−`a` is a `@rd`
3740−
3741−#### Produces
3742−
3743−A `dn`.
3744−
3745−#### Source
3746−
3747−```hoon
3748− ++ drg |= [a=@rd] ^- dn (drg:ma a)
3749−```
3750−
3751−#### Examples
3752−
3753−```
3754− > (drg:rd .~1.2246e3)
3755− [%d s=%.y e=-1 a=12.246]
3756−```
3757−
3758−---
3759−### `++grd:rd`
3760−
3761−Decimal float to `@rd`
3762−
3763−Converts `a` from decimal float to `@rd`.
3764−
3765−#### Accepts
3766−
3767−`a` is a `@dn`
3768−
3769−#### Produces
3770−
3771−A `@rd`.
3772−
3773−#### Source
3774−
3775−```hoon
3776− ++ grd |= [a=dn] ^- @rd (grd:ma a) :: decimal float to @rd
3777− --
3778−```
3779−
3780−#### Examples
3781−
3782−```
3783− > (grd:rd [%d s=%.y e=-1 a=12.246])
3784− .~1.2246e3
3785−```
3786−
3787−---
3788−### `++rs`
3789−
3790−Single-precision fp
3791−
3792−A container core for operations related to single-precision binary floats.
3793−
3794−`++rs` has four rounding modes: round to nearest (`$n`), round up (`$u`), round
3795−down (`$d`), and round to zero (`$z`).
3796−
3797−#### Source
3798−
3799−```hoon
3800− ++ rs
3801− ~% %rs +> ~
3802− ^?
3803− |_ r=$?($n $u $d $z)
3804−```
3805−
3806−---
3807−### `++ma:rs`
3808−
3809−Initialize `ff`
3810−
3811−Instantiates the core `ff`, giving values to its samples based on the
3812−configuration of the `rs` core.
3813−
3814−#### Source
3815−
3816−```hoon
3817− ++ ma
3818− %*(. ff w 8, p 23, b --127, r r)
3819−```
3820−
3821−#### Examples
3822−
3823−```
3824− > ~(ma rs %n)
3825− < 24.ltg
3826− {{{w/@ud p/@ud b/@sd} r/?($n $u $d $z)} <54.tyv 119.wim 31.ohr 1.jmk $143>}
3827− >
3828−```
3829−
3830−---
3831−### `++sea:rs`
3832−
3833−`@rs` to `fn`
3834−
3835−Converts `a` from `@rs` to `fn`.
3836−
3837−#### Accepts
3838−
3839−`a` is a `@rs`, an single-precision float.
3840−
3841−#### Produces
3842−
3843−An `fn`.
3844−
3845−#### Source
3846−
3847−```hoon
3848− ++ sea
3849− |= [a=@rs] (sea:ma a)
3850−```
3851−
3852−#### Examples
3853−
3854−```
3855− > (sea:rs .1.4e-43)
3856− [%f s=%.y e=-149 a=100]
3857−```
3858−
3859−---
3860−### `++bit:rs`
3861−
3862−`fn` to `@rs`
3863−
3864−Converts `a` from `fn` to `@rs`.
3865−
3866−#### Accepts
3867−
3868−`a` is an `fn`.
3869−
3870−#### Produces
3871−
3872−A `@rs`, a single-precision float.
3873−
3874−#### Source
3875−
3876−```hoon
3877− ++ bit
3878− |= [a=fn] ^- @rs (bit:ma a)
3879−```
3880−
3881−#### Examples
3882−
3883−```
3884− > (bit:rs [%f & -2 1.000])
3885− .2.5e2
3886−```
3887−
3888−---
3889−### `++add:rs`
3890−
3891−Add
3892−
3893−Produces the sum of `a` plus `b`.
3894−
3895−#### Accepts
3896−
3897−`a` is a `@rs`, a single-precision float.
3898−
3899−`b` is a `@rs`.
3900−
3901−#### Produces
3902−
3903−A `@rs`.
3904−
3905−#### Source
3906−
3907−```hoon
3908− ++ add ~/ %add
3909− |= [a=@rs b=@rs] ^- @rs
3910− ~_ leaf+"rs-fail"
3911− (add:ma a b)
3912−```
3913−
3914−#### Examples
3915−
3916−```
3917− > (add:rs .2.5e1 .2.5e2)
3918− .2.75e2
3919−```
3920−
3921−---
3922−### `++sub:rs`
3923−
3924−Subtract
3925−
3926−Subtracts `a` from `b`.
3927−
3928−#### Source
3929−
3930−```hoon
3931− ++ sub ~/ %sub
3932− |= [a=@rs b=@rs] ^- @rs
3933− ~_ leaf+"rs-fail"
3934− (sub:ma a b)
3935−```
3936−
3937−#### Examples
3938−
3939−```
3940− > (sub:rs .2.5e1 .2.5e2)
3941− .-2.25e2
3942−```
3943−
3944−---
3945−### `++mul:rs`
3946−
3947−Multiply
3948−
3949−Produces the product of `a` multiplied by `b`.
3950−
3951−#### Accepts
3952−
3953−`a` is a `@rs`, a single-precision float.
3954−
3955−`b` is a `@rs`.
3956−
3957−#### Produces
3958−
3959−A `@rs`.
3960−
3961−#### Source
3962−
3963−```hoon
3964− ++ mul ~/ %mul
3965− |= [a=@rs b=@rs] ^- @rs
3966− ~_ leaf+"rs-fail"
3967− (mul:ma a b)
3968−```
3969−
3970−#### Examples
3971−
3972−```
3973− > (mul:rs .2.5e1 .2.5e2)
3974− .6.25e3
3975−```
3976−
3977−---
3978−### `++div:rs`
3979−
3980−Divide
3981−
3982−Produces the quotient of `a` divided by `b`.
3983−
3984−#### Accepts
3985−
3986−`a` is a `@rs`, a single-precision float.
3987−
3988−`b` is a `@rs`.
3989−
3990−#### Produces
3991−
3992−A `@rs`.
3993−
3994−#### Source
3995−
3996−```hoon
3997− ++ div ~/ %div
3998− |= [a=@rs b=@rs] ^- @rs
3999− ~_ leaf+"rs-fail"
4000− (div:ma a b)
4001−```
4002−
4003−#### Examples
4004−
4005−```
4006− > (div:rs .4.5e1 .2.2e2)
4007− .2.0454545e-1
4008−```
4009−
4010−---
4011−### `++fma:rs`
4012−
4013−Fused multiply-add
4014−
4015−Produces the sum of `c` plus the product of `a` multiplied by `b`;
4016−`(a * b) + c`.
4017−
4018−#### Accepts
4019−
4020−`a` is a `@rs`, a single-precision float.
4021−
4022−`b` is a `@rs`.
4023−
4024−`c` is a `@rs`.
4025−
4026−#### Produces
4027−
4028−A `@rs`.
4029−
4030−#### Source
4031−
4032−```hoon
4033− ++ fma ~/ %fma
4034− |= [a=@rs b=@rs c=@rs] ^- @rs
4035− ~_ leaf+"rs-fail"
4036− (fma:ma a b c)
4037−```
4038−
4039−#### Examples
4040−
4041−```
4042− > (fma:rs .2.5e1 .2.5e2 .8.2e1)
4043− .6.332e3
4044−```
4045−
4046−---
4047−### `++sqt:rs`
4048−
4049−Square root
4050−
4051−Produces the square root of `a`.
4052−
4053−#### Accepts
4054−
4055−`a` is a `@rs`, a single-precision float.
4056−
4057−#### Produces
4058−
4059−A `@rs`.
4060−
4061−#### Source
4062−
4063−```hoon
4064− ++ sqt ~/ %sqt
4065− |= [a=@rs] ^- @rs
4066− ~_ leaf+"rs-fail"
4067− (sqt:ma a)
4068−```
4069−
4070−#### Examples
4071−
4072−```
4073− > (sqt:rs .2.5e2)
4074− .1.5811388e1
4075−```
4076−
4077−---
4078−### `++lth:rs`
4079−
4080−Less than
4081−
4082−Test whether `a` is less than `b`.
4083−
4084−#### Accepts
4085−
4086−`a` is a `@rs`, a single-precision float.
4087−
4088−`b` is a `@rs`.
4089−
4090−#### Produces
4091−
4092−A `@rs`.
4093−
4094−#### Source
4095−
4096−```hoon
4097− ++ lth ~/ %lth
4098− |= [a=@rs b=@rs]
4099− ~_ leaf+"rs-fail"
4100− (lth:ma a b)
4101−```
4102−
4103−#### Examples
4104−
4105−```
4106− > (lth:rs .9.9e1 .1.1e2)
4107− %.y
4108−
4109− > (lth:rs .9.9e1 .9.9e1)
4110− %.n
4111−```
4112−
4113−---
4114−### `++lte:rs`
4115−
4116−Less than or equal
4117−
4118−Test whether `a` is less than or equal to `b`.
4119−
4120−#### Accepts
4121−
4122−`a` is a `@rs`, a single-precision float.
4123−
4124−`b` is a `@rs`.
4125−
4126−#### Produces
4127−
4128−A `@rs`.
4129−
4130−#### Source
4131−
4132−```hoon
4133− ++ lte ~/ %lte
4134− |= [a=@rs b=@rs]
4135− ~_ leaf+"rs-fail"
4136− (lte:ma a b)
4137−```
4138−
4139−#### Examples
4140−
4141−```
4142− > (lte:rs .9.9e1 .1.1e2)
4143− %.y
4144−
4145− > (lte:rs .9.9e1 .9.9e1)
4146− %.y
4147−```
4148−
4149−---
4150−### `++equ:rs`
4151−
4152−Equals
4153−
4154−Test whether `a` is equal to `b`.
4155−
4156−#### Accepts
4157−
4158−`a` is a `@rs`, a single-precision float.
4159−
4160−`b` is a `@rs`.
4161−
4162−#### Produces
4163−
4164−A `@rs`.
4165−
4166−#### Source
4167−
4168−```hoon
4169− ++ equ ~/ %equ
4170− |= [a=@rs b=@rs]
4171− ~_ leaf+"rs-fail"
4172− (equ:ma a b)
4173−```
4174−
4175−#### Examples
4176−
4177−```
4178− > (equ:rs .9.9e1 .1.1e2)
4179− %.n
4180−
4181− > (equ:rs .9.9e1 .9.9e1)
4182− %.y
4183−```
4184−
4185−---
4186−### `++gte:rs`
4187−
4188−Greater than or equal
4189−
4190−Test whether `a` is greater than or equal to `b`.
4191−
4192−#### Accepts
4193−
4194−`a` is a `@rs`, a single-precision float.
4195−
4196−`b` is a `@rs`.
4197−
4198−#### Produces
4199−
4200−A `@rs`.
4201−
4202−#### Source
4203−
4204−```hoon
4205− ++ gte ~/ %gte
4206− |= [a=@rs b=@rs]
4207− ~_ leaf+"rs-fail"
4208− (gte:ma a b)
4209−```
4210−
4211−#### Examples
4212−
4213−```
4214− > (gte:rs .9.9e1 .9.9e1)
4215− %.y
4216−
4217− > (gte:rs .9.9e1 .9.2e2)
4218− %.n
4219−```
4220−
4221−---
4222−### `++gth:rs`
4223−
4224−Greater than
4225−
4226−Test whether `a` is greater than `b`.
4227−
4228−#### Accepts
4229−
4230−`a` is a `@rs`, a single-precision float.
4231−
4232−`b` is a `@rs`.
4233−
4234−#### Produces
4235−
4236−A `@rs`.
4237−
4238−#### Source
4239−
4240−```hoon
4241− ++ gth ~/ %gth
4242− |= [a=@rs b=@rs]
4243− ~_ leaf+"rs-fail"
4244− (gth:ma a b)
4245−```
4246−
4247−#### Examples
4248−
4249−```
4250− > (gth:rs .9.9e1 .9.2e2)
4251− %.n
4252−
4253− > (gth:rs .9.9e1 .9.9e1)
4254− %.n
4255−
4256− > (gth:rs .9.9e1 .1.9e1)
4257− %.y
4258−```
4259−
4260−---
4261−### `++sun:rs`
4262−
4263−Unsigned integer to `@rs`
4264−
4265−Converts `a` from an unsigned integer to `@rs`.
4266−
4267−#### Accepts
4268−
4269−`a` is an unsigned integer.
4270−
4271−#### Produces
4272−
4273−A `@rs`.
4274−
4275−#### Source
4276−
4277−```hoon
4278− ++ sun |= [a=@u] ^- @rs (sun:ma a)
4279−```
4280−
4281−#### Examples
4282−
4283−```
4284− > (sun:rs 343)
4285− .3.43e2
4286−```
4287−
4288−---
4289−### `++san:rs`
4290−
4291−Signed integer to `@rs`'
4292−
4293−Converts `a` from an unsigned integer to `@rs`.
4294−
4295−#### Accepts
4296−
4297−`a` is a signed integer.
4298−
4299−#### Produces
4300−
4301−A `@rs`.
4302−
4303−#### Source
4304−
4305−```hoon
4306− ++ san |= [a=@s] ^- @rs (san:ma a)
4307−```
4308−
4309−#### Examples
4310−
4311−```
4312− > (san:rs -343)
4313− .-3.43e2'
4314−```
4315−
4316−### `++sig:rs`
4317−
4318−Get sign
4319−
4320−Produces the sign of `a`.
4321−
4322−#### Accepts
4323−
4324−`a` is a `@rs`.
4325−
4326−#### Produces
4327−
4328−A `flag`.
4329−
4330−#### Source
4331−
4332−```hoon
4333− ++ sig |= [a=@rs] ^- ? (sig:ma a)
4334−```
4335−
4336−#### Examples
4337−
4338−```
4339− > (sig:rs .3.43e2)
4340− %.y
4341−
4342− > (sig:rs .-3.43e2)
4343− %.n
4344−```
4345−
4346−---
4347−### `++exp:rs`
4348−
4349−Get exponent
4350−
4351−Produces the exponent of `a`.
4352−
4353−#### Accepts
4354−
4355−`a` is a `@rs`.
4356−
4357−#### Produces
4358−
4359−A signed integer.
4360−
4361−#### Source
4362−
4363−```hoon
4364− ++ exp |= [a=@rs] ^- @s (exp:ma a)
4365−```
4366−
4367−#### Examples
4368−
4369−```
4370− > (exp:rs .-3.43e2)
4371− --8
4372−```
4373−
4374−---
4375−### `++toi:rs`
4376−
4377−Round to integer
4378−
4379−Rounds `a` to the nearest integer.
4380−
4381−#### Accepts
4382−
4383−`a` is a `@rs`.
4384−
4385−#### Produces
4386−
4387−A `unit` of `@s`.
4388−
4389−#### Source
4390−
4391−```hoon
4392− ++ toi |= [a=@rs] ^- (unit @s) (toi:ma a)
4393−```
4394−
4395−#### Examples
4396−
4397−```
4398− > (toi:rs .-3.43e2)
4399− [~ u=-343]
4400−```
4401−
4402−---
4403−### `++drg:rs`
4404−
4405−`@rs` to decimal float
4406−
4407−Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
4408−accurate results for rounded floats.
4409−
4410−#### Accepts
4411−
4412−`a` is a `@rs`
4413−
4414−#### Produces
4415−
4416−A `dn`.
4417−
4418−#### Source
4419−
4420−```hoon
4421− ++ drg |= [a=@rs] ^- dn (drg:ma a)
4422−```
4423−
4424−#### Examples
4425−
4426−```
4427− > (drg:rs .-3.43e2)
4428− [%d s=%.n e=--0 a=343]
4429−```
4430−
4431−---
4432−### `++grd:rs`
4433−
4434−Decimal float to `@rs`
4435−
4436−Converts `a` from `dn` to `@rs`.
4437−
4438−#### Accepts
4439−
4440−`a` is a `dn`.
4441−
4442−#### Produces
4443−
4444−A `@rs`.
4445−
4446−#### Source
4447−
4448−```hoon
4449− ++ grd |= [a=dn] ^- @rs (grd:ma a)
4450− --
4451−```
4452−
4453−#### Examples
4454−
4455−```
4456− > (grd:rs [%d s=%.n e=--0 a=343])
4457− .-3.43e2
4458−```
4459−
4460−---
4461−### `++rq`
4462−
4463−Quadruple-precision fp
4464−
4465−A container core for operations related to quadruple-precision binary floats.
4466−
4467−`++rq` has four rounding modes: round to nearest (`$n`), round up (`$u`), round
4468−down (`$d`), and round to zero (`$z`).
4469−
4470−#### Source
4471−
4472−```hoon
4473− ++ rq
4474− ~% %rq +> ~
4475− ^?
4476− |_ r=$?($n $u $d $z)
4477−```
4478−
4479−### `++ma:rq`
4480−
4481−Initialize `ff`
4482−
4483−Instantiates the core `ff`, giving values to its samples based on the
4484−configuration of the `rq` core.
4485−
4486−#### Source
4487−
4488−```hoon
4489− ++ ma
4490− %*(. ff w 15, p 112, b --16.383, r r)
4491−```
4492−
4493−---
4494−### `++sea:rq`
4495−
4496−`@rq` to `fn`
4497−
4498−Converts `a` from `@rq` to `fn`.
4499−
4500−#### Accepts
4501−
4502−`a` is a `@rq`, a quad-precision float.
4503−
4504−#### Produces
4505−
4506−An `fn`.
4507−
4508−#### Source
4509−
4510−```hoon
4511− ++ sea
4512− |= [a=@rq] (sea:ma a)
4513−```
4514−
4515−#### Examples
4516−
4517−```
4518− > (sea:rq .~~~1.05102e5)
4519− [%f s=%.y e=-96 a=8.327.038.336.574.210.409.756.656.268.214.272]
4520−```
4521−
4522−---
4523−### `++bit:rq`
4524−
4525−`fn` to `@rq`
4526−
4527−Converts `a` from `fn` to `@rq`.
4528−
4529−#### Accepts
4530−
4531−`a` is an `fn`.
4532−
4533−#### Produces
4534−
4535−A `@rq`, a quad-precision float.
4536−
4537−#### Source
4538−
4539−```hoon
4540− ++ bit
4541− |= [a=n] ^- @rq (bit:ma a)
4542−```
4543−
4544−#### Examples
4545−
4546−```
4547− > (bit:rq [%f s=%.y e=-96 a=8.327.038.336.574.210.409.756.656.268.214.272])
4548− .~~~1.05102e5
4549−```
4550−
4551−---
4552−### `++add:rq`
4553−
4554−Add
4555−
4556−Produces the sum of `a` plus `b`.
4557−
4558−#### Accepts
4559−
4560−`a` is a `@rq`, a quad-precision float.
4561−
4562−`b` is a `@rq`.
4563−
4564−#### Produces
4565−
4566−A `@rq`.
4567−
4568−#### Source
4569−
4570−```hoon
4571− ++ add ~/ %add
4572− |= [a=@rq b=@rq] ^- @rq
4573− ~_ leaf+"rq-fail"
4574− (add:ma a b)
4575−```
4576−
4577−#### Examples
4578−
4579−```
4580− > (add:rq .~~~-1.821e5 .~~~1.05102e5)
4581− .~~~-7.6998e4
4582−```
4583−
4584−---
4585−### `++sub:rq`
4586−
4587−Subtract
4588−
4589−Produces the difference of `a` minus `b`.
4590−
4591−#### Accepts
4592−
4593−`a` is a `@rq`, a quad-precision float.
4594−
4595−`b` is a `@rq`.
4596−
4597−#### Produces
4598−
4599−A `@rq`.
4600−
4601−#### Source
4602−
4603−```hoon
4604− ++ sub ~/ %sub
4605− |= [a=@rq b=@rq] ^- @rq
4606− ~_ leaf+"rq-fail"
4607− (sub:ma a b)
4608−```
4609−
4610−#### Examples
4611−
4612−```
4613− > (sub:rq .~~~1.821e5 .~~~1.05102e5)
4614− .~~~7.6998e4
4615−
4616− > (sub:rq .~~~1.821e5 .~~~-1.05102e5)
4617− .~~~2.87202e5
4618−```
4619−
4620−---
4621−### `++mul:rq`
4622−
4623−Multiply
4624−
4625−Produces the product of `a` times `b`.
4626−
4627−#### Accepts
4628−
4629−`a` is a `@rq`, a quad-precision float.
4630−
4631−`b` is a `@rq`.
4632−
4633−#### Produces
4634−
4635−A `@rq`.
4636−
4637−#### Source
4638−
4639−```hoon
4640− ++ mul ~/ %mul
4641− |= [a=@rq b=@rq] ^- @rq
4642− ~_ leaf+"rq-fail"
4643− (mul:ma a b)
4644−```
4645−
4646−#### Examples
4647−
4648−```
4649− > (mul:rq .~~~1.821e5 .~~~-1.05102e5)
4650− .~~~-1.91390742e10
4651−```
4652−
4653−---
4654−### `++div:rq`
4655−
4656−Divide
4657−
4658−Produces the product of `a` divided by `b`.
4659−
4660−#### Accepts
4661−
4662−`a` is a `@rq`, a quad-precision float.
4663−
4664−`b` is a `@rq`.
4665−
4666−#### Produces
4667−
4668−A `@rq`.
4669−
4670−#### Source
4671−
4672−```hoon
4673− ++ div ~/ %div
4674− |= [a=@rq b=@rq] ^- @rq
4675− ~_ leaf+"rq-fail"
4676− (div:ma a b)
4677−```
4678−
4679−#### Examples
4680−
4681−```
4682− > (div:rq .~~~1.821e5 .~~~1.05102e3)
4683− .~~~1.732602614602957127361991208540275e2
4684−```
4685−
4686−---
4687−### `++fma:rq`
4688−
4689−Fused multiply-add
4690−
4691−Produces the sum of `c` plus the product of `a` multiplied by `b`;
4692−`(a * b) + c`.
4693−
4694−#### Accepts
4695−
4696−`a` is a `@rq`, a quad-precision float.
4697−
4698−`b` is a `@rq`.
4699−
4700−`c` is a `@rq`.
4701−
4702−#### Produces
4703−
4704−A `@rq`.
4705−
4706−#### Source
4707−
4708−```hoon
4709− ++ fma ~/ %fma
4710− |= [a=@rq b=@rq c=@rq] ^- @rq
4711− ~_ leaf+"rq-fail"
4712− (fma:ma a b c)
4713−```
4714−
4715−#### Examples
4716−
4717−```
4718− > (fma:rq .~~~1.821e5 .~~~-1.05102e2 .~~~6.2044e7)
4719− .~~~4.29049258e7
4720−```
4721−
4722−---
4723−### `++sqt:rq`
4724−
4725−Square root
4726−
4727−Produces the square root of `a`.
4728−
4729−#### Accepts
4730−
4731−`a` is a `@rq`, a quad-precision float.
4732−
4733−#### Produces
4734−
4735−A `@rq`.
4736−
4737−#### Source
4738−
4739−```hoon
4740− ++ sqt ~/ %sqt
4741− |= [a=@rq] ^- @rq
4742− ~_ leaf+"rq-fail"
4743− (sqt:ma a)
4744−```
4745−
4746−#### Examples
4747−
4748−```
4749− > (sqt:rq .~~~6.2044e7)
4750− .~~~7.876801381271461258959876570289002e3
4751−```
4752−
4753−---
4754−### `++lth:rq`
4755−
4756−Less than
4757−
4758−Tests whether `a` is less than `b`.
4759−
4760−#### Accepts
4761−
4762−`a` is a `@rq`, a quad-precision float.
4763−
4764−`b` is a `@rq`.
4765−
4766−#### Produces
4767−
4768−A `@rq`.
4769−
4770−#### Source
4771−
4772−```hoon
4773− ++ lth ~/ %lth
4774− |= [a=@rq b=@rq]
4775− ~_ leaf+"rq-fail"
4776− (lth:ma a b)
4777−```
4778−
4779−
4780−#### Examples
4781−
4782−```
4783− > (lth:rq .~~~1.2044e7 (mul:rq .~~~9.02e2 .~~~7.114e3))
4784− %.n
4785−
4786− > (lth:rq .~~~1.2044e7 (mul:rq .~~~9.02e3 .~~~7.114e3))
4787− %.y
4788−```
4789−
4790−---
4791−### `++lte:rq`
4792−
4793−Less than or equal
4794−
4795−Tests whether `a` is less than or equal to `b`.
4796−
4797−#### Accepts
4798−
4799−`a` is a `@rq`, a quad-precision float.
4800−
4801−`b` is a `@rq`.
4802−
4803−#### Produces
4804−
4805−A `@rq`.
4806−
4807−#### Source
4808−
4809−```hoon
4810− ++ lte ~/ %lte
4811− |= [a=@rq b=@rq]
4812− ~_ leaf+"rq-fail"
4813− (lte:ma a b)
4814−```
4815−
4816−#### Examples
4817−
4818−```
4819− > (lte:rq .~~~1.2044e7 (mul:rq .~~~9.02e2 .~~~7.114e3))
4820− %.n
4821−
4822− > (lte:rq .~~~1.2044e7 (mul:rq .~~~9.02e3 .~~~7.114e3))
4823− %.y
4824−
4825− > (lte:rq .~~~1.2044e7 .~~~1.2044e7)
4826− %.y
4827−```
4828−
4829−---
4830−### `++equ:rq`
4831−
4832−Equals
4833−
4834−Tests whether `a` is equal to `b`.
4835−
4836−#### Accepts
4837−
4838−`a` is a `@rq`, a quad-precision float.
4839−
4840−`b` is a `@rq`.
4841−
4842−#### Produces
4843−
4844−A `@rq`.
4845−
4846−#### Source
4847−
4848−```hoon
4849− ++ equ ~/ %equ
4850− |= [a=@rq b=@rq]
4851− ~_ leaf+"rq-fail"
4852− (equ:ma a b)
4853−```
4854−
4855−#### Examples
4856−
4857−```
4858− > (equ:rq .~~~1.2044e7 .~~~1.2044e7)
4859− %.y
4860−
4861− > (equ:rq .~~~2.2044e7 .~~~1.2044e7)
4862− %.n
4863−```
4864−
4865−---
4866−### `++gte:rq`
4867−
4868−Greater than or equal
4869−
4870−Tests whether `a` is greater than or equal to `b`.
4871−
4872−#### Accepts
4873−
4874−`a` is a `@rq`, a quad-precision float.
4875−
4876−`b` is a `@rq`.
4877−
4878−#### Produces
4879−
4880−A `@rq`.
4881−
4882−#### Source
4883−
4884−```hoon
4885− ++ gte ~/ %gte
4886− |= [a=@rq b=@rq]
4887− ~_ leaf+"rq-fail"
4888− (gte:ma a b)
4889−```
4890−
4891−#### Examples
4892−
4893−```
4894− > (gte:rq .~~~1.2044e7 .~~~1.2044e7)
4895− %.y
4896−
4897− > (gte:rq .~~~2.2044e7 .~~~1.2044e7)
4898− %.y
4899−
4900− > (gte:rq .~~~1.2044e7 .~~~2.2044e7)
4901− %.n
4902−```
4903−
4904−---
4905−### `++gth:rq`
4906−
4907−Tests whether `a` is greater than `b`.
4908−
4909−#### Accepts
4910−
4911−`a` is a `@rq`, a quad-precision float.
4912−
4913−`b` is a `@rq`.
4914−
4915−#### Produces
4916−
4917−A `@rq`.
4918−
4919−#### Source
4920−
4921−```hoon
4922− ++ gth ~/ %gth
4923− |= [a=@rq b=@rq]
4924− ~_ leaf+"rq-fail"
4925− (gth:ma a b)
4926−```
4927−
4928−#### Examples
4929−
4930−```
4931− > (gth:rq .~~~1.2044e7 .~~~1.2044e7)
4932− %.n
4933−
4934− > (gth:rq .~~~2.2044e7 .~~~1.2044e7)
4935− %.y
4936−
4937− > (gth:rq .~~~1.2044e7 .~~~2.2044e7)
4938− %.n
4939−```
4940−
4941−---
4942−### `++sun:rq`
4943−
4944−Unsigned integer to `@rq`
4945−
4946−Converts `@` from an unsigned integer to `@rq`.
4947−
4948−#### Accepts
4949−
4950−`a` is a `@u`, an unsigned integer.
4951−
4952−#### Produces
4953−
4954−A `@rq`, a quad-precision float.
4955−
4956−#### Source
4957−
4958−```hoon
4959− ++ sun |= [a=@u] ^- @rq (sun:ma a)
4960−```
4961−
4962−#### Examples
4963−
4964−```
4965− > (sun:rq 205)
4966− .~~~2.05e2
4967−```
4968−
4969−---
4970−### `++san:rq`
4971−
4972−Signed integer to `rq`
4973−
4974−Converts `@` from a signed integer to `@rq`.
4975−
4976−#### Accepts
4977−
4978−`a` is a `@s`, a signed integer.
4979−
4980−#### Produces
4981−
4982−A `@rq`, a quad-precision float.
4983−
4984−#### Source
4985−
4986−```hoon
4987− ++ san |= [a=@s] ^- @rq (san:ma a)
4988−```
4989−
4990−#### Examples
4991−
4992−```
4993− > (san:rq -205)
4994− .~~~-2.05e2
4995−```
4996−
4997−---
4998−### `++sig:rq`
4999−
5000−Get sign
5001−
5002−Produces the sign of `a`.
5003−
5004−#### Accepts
5005−
5006−`a` is a `@rq`, a quad-precision float.
5007−
5008−#### Produces
5009−
5010−A `flag`.
5011−
5012−#### Source
5013−
5014−```hoon
5015− ++ sig |= [a=@rq] ^- ? (sig:ma a)
5016−```
5017−
5018−#### Examples
5019−
5020−```
5021− > (sig:rq .~~~-2.05e2)
5022− %.n
5023−```
5024−
5025−---
5026−### `++exp:rq`
5027−
5028−Get exponent
5029−
5030−Gets the exponent of `a`.
5031−
5032−#### Accepts
5033−
5034−`a` is a `@rq`, a quad-precision float.
5035−
5036−#### Produces
5037−
5038−A `@s`, a signed integer.
5039−
5040−#### Source
5041−
5042−```hoon
5043− ++ exp |= [a=@rq] ^- @s (exp:ma a)
5044−```
5045−
5046−#### Examples
5047−
5048−```
5049− > (exp:rq .~~~-2.05e2)
5050− --7
5051−```
5052−
5053−---
5054−### `++toi:rq`
5055−
5056−Round to integer
5057−
5058−Rounds `a` to the nearest integer.
5059−
5060−#### Accepts
5061−
5062−`a` is a `@rq`, a quad-precision float.
5063−
5064−#### Produces
5065−
5066−A `unit` of `@s`.
5067−
5068−#### Source
5069−
5070−```hoon
5071− ++ toi |= [a=@rq] ^- (unit @s) (toi:ma a)
5072−```
5073−
5074−#### Examples
5075−
5076−```
5077− > (toi:rq .~~~-2.085e2)
5078− [~ u=-208]
5079−
5080− > (toi:rq .~~~-2.08e2)
5081− [~ u=-208]
5082−```
5083−
5084−---
5085−### `++drg:rq`
5086−
5087−`@rq` to decimal float
5088−
5089−Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
5090−accurate results for rounded floats.
5091−
5092−#### Accepts
5093−
5094−`a` is a `@rq`, a quad-precision float.
5095−
5096−#### Produces
5097−
5098−A `dn`.
5099−
5100−#### Source
5101−
5102−```hoon
5103− ++ drg |= [a=@rq] ^- dn (drg:ma a) :: @rq to decimal float
5104−```
5105−
5106−#### Examples
5107−
5108−```
5109− > (drg:rq .~~~-2.085e2)
5110− [%d s=%.n e=-1 a=2.085]
5111−
5112− > (drg:rq .~~~-2.08e2)
5113− [%d s=%.n e=--0 a=208]
5114−```
5115−
5116−---
5117−### `++grd:rq`
5118−
5119−Decimal float to `@rq`
5120−
5121−Converts `a` from `dn` to `@rq`.
5122−
5123−#### Accepts
5124−
5125−`a` is `dn`.
5126−
5127−`a` is a `@rq`.
5128−
5129−#### Produces
5130−
5131−A `@rq`, a quad-precision float.
5132−
5133−#### Source
5134−
5135−```hoon
5136− ++ grd |= [a=dn] ^- @rq (grd:ma a)
5137− --
5138−```
5139−
5140−#### Examples
5141−
5142−```
5143− > (grd:rq [%d s=%.n e=--0 a=343])
5144− .~~~-3.43e2
5145−```
5146−
5147−---
5148−### `++rh`
5149−
5150−Half-precision fp
5151−
5152−A container core for operations related to half-precision binary floats.
5153−
5154−`++rh` has four rounding modes: round to nearest (`$n`), round up (`$u`), round
5155−down (`$d`), and round to zero (`$z`).
5156−
5157−#### Source
5158−
5159−```hoon
5160− ++ rh
5161− ~% %rh +> ~
5162− ^?
5163− |_ r=$?($n $u $d $z)
5164−```
5165−
5166−---
5167−### `++ma:rh`
5168−
5169−Initialize `ff`
5170−
5171−Instantiates the core `ff`, giving values to its samples based on the
5172−configuration of the `rh` core.
5173−
5174−#### Source
5175−
5176−```hoon
5177− ++ ma
5178− %*(. ff w 5, p 10, b --15, r r)
5179−```
5180−
5181−---
5182−### `++sea:rh`
5183−
5184−`@rh` to `fn`
5185−
5186−Converts `a` from `@rh` to `fn`.
5187−
5188−#### Accepts
5189−
5190−`a` is a `@rh`, a half-precision float.
5191−
5192−#### Produces
5193−
5194−An `fn`.
5195−
5196−#### Source
5197−
5198−```hoon
5199− ++ sea
5200− |= [a=@rh] (sea:ma a)
5201−```
5202−
5203−#### Examples
5204−
5205−```
5206− > (sea:rh .~~1.22e-5)
5207− [%f s=%.y e=-24 a=205]
5208−```
5209−
5210−---
5211−### `++bit:rh`
5212−
5213−`fn` to `@rh`
5214−
5215−Converts `a` from `fn` to `@rh`.
5216−
5217−#### Accepts
5218−
5219−`a` is an `fn`.
5220−
5221−#### Produces
5222−
5223−A `@rh`, a half-precision float.
5224−
5225−#### Source
5226−
5227−```hoon
5228− ++ bit
5229− |= [a=fn] ^- @rh (bit:ma a)
5230−```
5231−
5232−#### Examples
5233−
5234−```
5235− > (bit:rh [%f s=%.y e=-24 a=205])
5236− .~~1.22e-5
5237−```
5238−
5239−---
5240−### `++add:rh`
5241−
5242−Produces the sum of `a` plus `b`.
5243−
5244−#### Accepts
5245−
5246−`a` is a `@rh`, a half-precision float.
5247−
5248−`b` is a `@rh`.
5249−
5250−#### Produces
5251−
5252−A `@rh`.
5253−
5254−#### Source
5255−
5256−```hoon
5257− ++ add ~/ %add
5258− |= [a=@rh b=@rh] ^- @rh
5259− ~_ leaf+"rh-fail"
5260− (add:ma a b)
5261−```
5262−
5263−#### Examples
5264−
5265−```
5266− > (add:rh .~~1.82e2 .~~1.02e2)
5267− .~~2.84e2
5268−```
5269−
5270−---
5271−### `++sub:rh`
5272−
5273−Subtract
5274−
5275−Produces the difference of `a` minus `b`.
5276−
5277−#### Accepts
5278−
5279−`a` is a `@rh`, a half-precision float.
5280−
5281−`b` is a `@rh`.
5282−
5283−#### Produces
5284−
5285−A `@rh`.
5286−
5287−#### Source
5288−
5289−```hoon
5290− ++ sub ~/ %sub
5291− |= [a=@rh b=@rh] ^- @rh
5292− ~_ leaf+"rh-fail"
5293− (sub:ma a b)
5294−```
5295−
5296−#### Examples
5297−
5298−```
5299− > (sub:rh .~~1.821e2 .~~1.051e2)
5300− .~~7.7e1
5301−
5302− > (sub:rh .~~1.821e2 .~~6.051e2)
5303− .~~-4.228e2
5304−```
5305−
5306−---
5307−### `++mul:rh`
5308−
5309−Multiply
5310−
5311−Produces the product of `a` times `b`.
5312−
5313−#### Accepts
5314−
5315−`a` is a `@rh`, a quad-precision float.
5316−
5317−`b` is a `@rh`.
5318−
5319−#### Produces
5320−
5321−A `@rh`.
5322−
5323−#### Source
5324−
5325−```hoon
5326− ++ mul ~/ %mul
5327− |= [a=@rh b=@rh] ^- @rh
5328− ~_ leaf+"rh-fail"
5329− (mul:ma a b)
5330−```
5331−
5332−#### Examples
5333−
5334−```
5335− > (mul:rh .~~1.821e1 .~~-1.05102e2)
5336− .~~-1.913e3
5337−```
5338−
5339−---
5340−### `++div:rh`
5341−
5342−Divide
5343−
5344−Produces the product of `a` divided by `b`.
5345−
5346−#### Accepts
5347−
5348−`a` is a `@rh`, a half-precision float.
5349−
5350−`b` is a `@rh`.
5351−
5352−#### Produces
5353−
5354−A `@rh`.
5355−
5356−#### Source
5357−
5358−```hoon
5359− ++ div ~/ %div
5360− |= [a=@rh b=@rh] ^- @rh
5361− ~_ leaf+"rh-fail"
5362− (div:ma a b)
5363−```
5364−
5365−#### examples
5366−
5367−```
5368− > (div:rh .~~1.821e3 .~~1.05102e2)
5369− .~~1.731e1
5370−```
5371−
5372−---
5373−### `++fma:rh`
5374−
5375−Fused multiply-add
5376−
5377−Produces the sum of `c` plus the product of `a` multiplied by `b`;
5378−`(a * b) + c`.
5379−
5380−#### Accepts
5381−
5382−`a` is a `@rh`, a half-precision float.
5383−
5384−`b` is a `@rh`.
5385−
5386−`c` is a `@rh`.
5387−
5388−#### Produces
5389−
5390−A `@rh`.
5391−
5392−#### Source
5393−
5394−```hoon
5395− ++ fma ~/ %fma
5396− |= [a=@rh b=@rh c=@rh] ^- @rh
5397− ~_ leaf+"rh-fail"
5398− (fma:ma a b c)
5399−```
5400−
5401−#### Examples
5402−
5403−```
5404− > (fma:rh .~~1.821e4 .~~-1.05102e2 .~~6.2044e3)
5405− .~~-6.55e4
5406−```
5407−
5408−---
5409−### `++sqt:rh`
5410−
5411−Square root
5412−
5413−Produces the square root of `a`.
5414−
5415−#### Accepts
5416−
5417−`a` is a `@rh`, a half-precision float.
5418−
5419−#### Produces
5420−
5421−A `@rh`.
5422−
5423−#### Source
5424−
5425−```hoon
5426− ++ sqt ~/ %sqt
5427− |= [a=@rh] ^- @rh
5428− ~_ leaf+"rh-fail"
5429− (sqt:ma a)
5430−```
5431−
5432−#### Source
5433−
5434−```hoon
5435− > (sqt:rh .~~6.24e4)
5436− .~~2.498e2
5437−```
5438−
5439−---
5440−### `++lth:rh`
5441−
5442−Less than
5443−
5444−Tests whether `a` is less than `b`.
5445−
5446−#### Accepts
5447−
5448−`a` is a `@rh`, a half-precision float.
5449−
5450−`b` is a `@rh`.
5451−
5452−#### Produces
5453−
5454−A `@rh`.
5455−
5456−#### Source
5457−
5458−```hoon
5459− ++ lth ~/ %lth
5460− |= [a=@rh b=@rh]
5461− ~_ leaf+"rh-fail"
5462− (lth:ma a b)
5463−```
5464−
5465−#### Examples
5466−
5467−```
5468− > (lth:rh .~~1.2e5 (mul:rh .~~9.02e2 .~~7.114e2))
5469− %.n
5470−
5471− > (lth:rh .~~1.2e3 (mul:rh .~~9.02e1 .~~7.114e2))
5472− %.y
5473−```
5474−
5475−---
5476−### `++lte:rh`
5477−
5478−Less than or equal
5479−
5480−Tests whether `a` is less than or equal to `b`.
5481−
5482−#### Accepts
5483−
5484−`a` is a `@rh`, a half-precision float.
5485−
5486−`b` is a `@rh`.
5487−
5488−#### Produces
5489−
5490−A `@rh`.
5491−
5492−#### Source
5493−
5494−```hoon
5495− ++ lte ~/ %lte
5496− |= [a=@rh b=@rh]
5497− ~_ leaf+"rh-fail"
5498− (lte:ma a b)
5499−```
5500−
5501−#### Examples
5502−
5503−```
5504− > (lte:rh .~~1.2e5 (mul:rh .~~9.02e2 .~~7.114e2))
5505− %.n
5506−
5507− > (lte:rh .~~1.2e3 (mul:rh .~~9.02e1 .~~7.114e2))
5508− %.y
5509−
5510− > (lte:rh .~~1.2e3 .~~1.2e3)
5511− %.y
5512−```
5513−
5514−---
5515−### `++equ:rh`
5516−
5517−Equals
5518−
5519−Tests whether `a` is equal to `b`.
5520−
5521−#### Accepts
5522−
5523−`a` is a `@rh`, a half-precision float.
5524−
5525−`b` is a `@rh`.
5526−
5527−#### Produces
5528−
5529−A `@rh`.
5530−
5531−#### Source
5532−
5533−```hoon
5534− ++ equ ~/ %equ
5535− |= [a=@rh b=@rh]
5536− ~_ leaf+"rh-fail"
5537− (equ:ma a b)
5538−```
5539−
5540−#### Examples
5541−
5542−```
5543− > (equ:rh .~~1.24e4 .~~1.24e4)
5544− %.y
5545−
5546− > (equ:rh .~~2.24e4 .~~1.24e4)
5547− %.n
5548−```
5549−
5550−---
5551−### `++gte:rh`
5552−
5553−Greater than or equal
5554−
5555−Tests whether `a` is greater than or equal to `b`.
5556−
5557−#### Accepts
5558−
5559−`a` is a `@rh`, a half-precision float.
5560−
5561−`b` is a `@rh`.
5562−
5563−#### Produces
5564−
5565−A `@rh`.
5566−
5567−#### Source
5568−
5569−```hoon
5570− ++ gte ~/ %gte
5571− |= [a=@rh b=@rh]
5572− ~_ leaf+"rh-fail"
5573− (gte:ma a b)
5574−```
5575−
5576−#### Examples
5577−
5578−```
5579− > (gte:rh .~~1.24e4 .~~1.24e4)
5580− %.y
5581−
5582− > (gte:rh .~~2.24e4 .~~1.24e4)
5583− %.y
5584−
5585− > (gte:rh .~~1.24e4 .~~2.24e4)
5586− %.n
5587−```
5588−
5589−---
5590−### `++gth:rh`
5591−
5592−Tests whether `a` is greater than `b`.
5593−
5594−#### Accepts
5595−
5596−`a` is a `@rh`, a half-precision float.
5597−
5598−`b` is a `@rh`.
5599−
5600−#### Produces
5601−
5602−A `@rh`.
5603−
5604−#### Source
5605−
5606−```hoon
5607− ++ gth ~/ %gth
5608− |= [a=@rh b=@rh]
5609− ~_ leaf+"rh-fail"
5610− (gth:ma a b)
5611−```
5612−
5613−#### Examples
5614−
5615−```
5616− > (gth:rh .~~1.24e4 .~~1.244e4)
5617− %.n
5618−
5619− > (gth:rh .~~2.24e4 .~~1.24e4)
5620− %.y
5621−
5622− > (gth:rh .~~1.24e4 .~~2.24e4)
5623− %.n
5624−```
5625−
5626−---
5627−
5628−### `++tos:rh`
5629−
5630−`@rh` to `@rs`
5631−
5632−Converts `@` from `@rh` to `@rs`.
5633−
5634−#### Accepts
5635−
5636−`a` is a `@rh`, a half-precision float.
5637−
5638−#### Produces
5639−
5640−A `@rs`, a single-precision float.
5641−
5642−#### Source
5643−
5644−```hoon
5645− ++ tos |= {a/@rh} (bit:rs (sea a))
5646−```
5647−
5648−#### Examples
5649−
5650−```
5651− > (tos:rh .~~2.5e2)
5652− .2.5e2
5653−```
5654−
5655−---
5656−### `++fos:rh`
5657−
5658−`@rs` to `@rh`
5659−
5660−Converts `@` from `@rs` to `@rh`.
5661−
5662−#### Accepts
5663−
5664−`a` is a `@rs`, a single-precision float.
5665−
5666−#### Produces
5667−
5668−A `@rh`, a half-precision float.
5669−
5670−#### Source
5671−
5672−```hoon
5673− ++ fos |= {a/@rs} (bit (sea:rs a))
5674−```
5675−
5676−#### Examples
5677−
5678−```
5679− > (fos:rh .2.5e2)
5680− .~~2.5e2
5681−```
5682−
5683−---
5684−### `++sun:rh`
5685−
5686−Unsigned integer to `@rh`
5687−
5688−Converts `@` from an unsigned integer to `@rh`.
5689−
5690−#### Accepts
5691−
5692−`a` is a `@u`, an unsigned integer.
5693−
5694−#### Produces
5695−
5696−A `@rh`, a half-precision float.
5697−
5698−#### Source
5699−
5700−```hoon
5701− ++ sun |= [a=@u] ^- @rh (sun:ma a)
5702−```
5703−
5704−#### Examples
5705−
5706−```
5707− > (sun:rh 205)
5708− .~~2.05e2
5709−```
5710−
5711−---
5712−### `++san:rh`
5713−
5714−Signed integer to `@rh`
5715−
5716−Converts `@` from a signed integer to `@rh`.
5717−
5718−#### Accepts
5719−
5720−`a` is a `@s`, a signed integer.
5721−
5722−#### Produces
5723−
5724−A `@rh`, a half-precision float.
5725−
5726−#### Source
5727−
5728−```hoon
5729− ++ san |= [a=@s] ^- @rh (san:ma a)
5730−```
5731−
5732−#### Examples
5733−
5734−```
5735− > (san:rh -205)
5736− .~~-2.05e2
5737−```
5738−
5739−---
5740−### `++sig:rh`
5741−
5742−Get sign
5743−
5744−Produces the sign of `a`.
5745−
5746−#### Accepts
5747−
5748−`a` is a `@rh`, a half-precision float.
5749−
5750−#### Produces
5751−
5752−A `flag`.
5753−
5754−#### Source
5755−
5756−```hoon
5757− ++ sig |= [a=@rh] ^- ? (sig:ma a)
5758−```
5759−
5760−#### Examples
5761−
5762−```
5763− > (sig:rh .~~-2.05e2)
5764− %.n
5765−```
5766−
5767−---
5768−### `++exp:rh`
5769−
5770−Get exponent
5771−
5772−Gets the exponent of `a`.
5773−
5774−#### Accepts
5775−
5776−`a` is a `@rh`, a half-precision float.
5777−
5778−#### Produces
5779−
5780−A `@s`, a signed integer.
5781−
5782−#### Source
5783−
5784−```hoon
5785− ++ exp |= [a=@rh] ^- @s (exp:ma a)
5786−```
5787−
5788−#### Examples
5789−
5790−```
5791− > (exp:rh .~~-2.05e2)
5792− --7
5793−```
5794−
5795−---
5796−### `++toi:rh`
5797−
5798−Round to integer
5799−
5800−Rounds `a` to the nearest integer.
5801−
5802−#### Accepts
5803−
5804−`a` is a `@rh`, a half-precision float.
5805−
5806−#### Produces
5807−
5808−A `unit` of `@s`.
5809−
5810−#### Source
5811−
5812−```hoon
5813− ++ toi |= [a=@rh] ^- (unit @s) (toi:ma a)
5814−```
5815−
5816−#### Examples
5817−
5818−```
5819− > (toi:rh .~~-2.085e2)
5820− [~ u=-208]
5821−
5822− > (toi:rh .~~-2.08e2)
5823− [~ u=-208]
5824−```
5825−
5826−---
5827−### `++drg:rh`
5828−
5829−`@rh` to decimal float
5830−
5831−Produces the decimal form of `a` using the Dragon4 algorithm. Guarantees
5832−accurate results for rounded floats.
5833−
5834−#### Accepts
5835−
5836−`a` is a `@rh`, a half-precision float.
5837−
5838−#### Produces
5839−
5840−A `dn`.
5841−
5842−#### Source
5843−
5844−```hoon
5845− ++ drg |= [a=@rh] ^- dn (drg:ma a)
5846−```
5847−
5848−#### Examples
5849−
5850−```
5851− > (drg:rh .~~-2.085e2)
5852− [%d s=%.n e=-1 a=2.085]
5853−
5854− > (drg:rh .~~-2.08e2)
5855− [%d s=%.n e=--0 a=208]
5856−```
5857−
5858−---
5859−### `++grd:rh`
5860−
5861−Decimal float to `@rh`
5862−
5863−Converts `a` from `dn` to `@rh`.
5864−
5865−#### Accepts
5866−
5867−`a` is `dn`.
5868−
5869−`a` is a `@rh`.
5870−
5871−#### Produces
5872−
5873−A `@rh`, a a half-precision float.
5874−
5875−#### Source
5876−
5877−```hoon
5878− ++ grd |= [a=dn] ^- @rh (grd:ma a)
5879− --
5880−```
5881−
5882−#### Examples
5883−
5884−```
5885− > (grd:rh [%d s=%.n e=--0 a=343])
5886− .~~-3.43e2
5887−```
5888−
5889−---
reference/library/3c.mddeleted−649
@@ -1,649 +0,0 @@
1−+++
2−title = "3c: Urbit Time"
3−weight = 23
4−template = "doc.html"
5−aliases = ["/docs/reference/library/3c"]
6−+++
7−### `++yall`
8−
9−Time since beginning of time
10−
11−Produce the date tuple of `[y=@ud m=@ud d=@ud]` of the year, month, and
12−day from a number of days from the beginning of the Gregorian calendar.
13−
14−#### Accepts
15−
16−`day` is a an unsigned decimal.
17−
18−#### Produces
19−
20−A cell of unsigned decimals.
21−
22−#### Source
23−
24−```hoon
25− ++ yall
26− |= day=@ud
27− ^- [y=@ud m=@ud d=@ud]
28− =+ [era=0 cet=0 lep=*?]
29− => .(era (div day era:yo), day (mod day era:yo))
30− => ^+ .
31− ?: (lth day +(cet:yo))
32− .(lep &, cet 0)
33− => .(lep |, cet 1, day (sub day +(cet:yo)))
34− .(cet (add cet (div day cet:yo)), day (mod day cet:yo))
35− =+ yer=(add (mul 400 era) (mul 100 cet))
36− |- ^- [y=@ud m=@ud d=@ud]
37− =+ dis=?:(lep 366 365)
38− ?. (lth day dis)
39− =+ ner=+(yer)
40− $(yer ner, day (sub day dis), lep =(0 (end 0 2 ner)))
41− |- ^- [y=@ud m=@ud d=@ud]
42− =+ [mot=0 cah=?:(lep moy:yo moh:yo)]
43− |- ^- [y=@ud m=@ud d=@ud]
44− =+ zis=(snag mot cah)
45− ?: (lth day zis)
46− [yer +(mot) +(day)]
47− $(mot +(mot), day (sub day zis))
48−```
49−
50−#### Examples
51−
52−```
53− > (yall 198)
54− [y=0 m=7 d=17]
55−
56− > (yall 90.398)
57− [y=247 m=7 d=3]
58−
59− > (yall 0)
60− [y=0 m=1 d=1]
61−```
62−
63−
64−---
65−### `++yawn`
66−
67−Days since beginning of time
68−
69−Inverse of `yall`, computes number of days A.D. from y/m/d date as the
70−tuple `[yer=@ud mot=@ud day=@ud]`.
71−
72−#### Accepts
73−
74−`yer` is an unsigned decimal.
75−
76−`mon` is an unsigned decimal.
77−
78−`day` is an unsigned decimal.
79−
80−#### Produces
81−
82−An unsigned decimal.
83−
84−#### Source
85−
86−```hoon
87− ++ yawn
88− |= [yer=@ud mot=@ud day=@ud]
89− ^- @ud
90− => .(mot (dec mot), day (dec day))
91− => ^+ .
92− %= .
93− day
94− =+ cah=?:((yelp yer) moy:yo moh:yo)
95− |- ^- @ud
96− ?: =(0 mot)
97− day
98− $(mot (dec mot), cah (slag 1 cah), day (add day (snag 0 cah)))
99− ==
100− |- ^- @ud
101− ?. =(0 (mod yer 4))
102− =+ ney=(dec yer)
103− $(yer ney, day (add day ?:((yelp ney) 366 365)))
104− ?. =(0 (mod yer 100))
105− =+ nef=(sub yer 4)
106− $(yer nef, day (add day ?:((yelp nef) 1.461 1.460)))
107− ?. =(0 (mod yer 400))
108− =+ nec=(sub yer 100)
109− $(yer nec, day (add day ?:((yelp nec) 36.525 36.524)))
110− (add day (mul (div yer 400) (add 1 (mul 4 36.524))))
111−```
112−
113−#### Examples
114−
115−```
116− > (yawn 2.018 7 4)
117− 737.244
118−
119− > (yawn 1.776 7 4)
120− 648.856
121−
122− > (yawn 1.990 10 11)
123− 727.116
124−```
125−
126−---
127−### `++year`
128−
129−Date to @d
130−
131−Accept a parsed date of form `[[a=? y=@ud] m=@ud t=tarp]` and produce
132−its `@d` representation.
133−
134−#### Accepts
135−
136−`det` is a `date`
137−
138−#### Produces
139−
140−A `@d`.
141−
142−#### Source
143−
144−```hoon
145− ++ year
146− |= det=date
147− ^- @da
148− =+ ^= yer
149− ?: a.det
150− (add 292.277.024.400 y.det)
151− (sub 292.277.024.400 (dec y.det))
152− =+ day=(yawn yer m.det d.t.det)
153− (yule day h.t.det m.t.det s.t.det f.t.det)
154−```
155−
156−#### Examples
157−
158−```
159− > (year [[a=%.y y=2.014] m=8 t=[d=4 h=20 m=4 s=57 f=~[0xd940]]])
160− 0x8000000d227df4e9d940000000000000
161−```
162−
163−---
164−### `++yell`
165−
166−Tarp from atomic date
167−
168−Produce a parsed daily time format from, `@d`, an atomic date.
169−
170−#### Accepts
171−
172−`now` is a `@d`.
173−
174−#### Produces
175−
176−A `tarp`.
177−
178−#### Source
179−
180−```hoon
181− ++ yell
182− |= now=@d
183− ^- tarp
184− =+ sec=(rsh 6 1 now)
185− =+ ^= fan
186− =+ [muc=4 raw=(end 6 1 now)]
187− |- ^- (list @ux)
188− ?: |(=(0 raw) =(0 muc))
189− ~
190− => .(muc (dec muc))
191− [(cut 4 [muc 1] raw) $(raw (end 4 muc raw))]
192− =+ day=(div sec day:yo)
193− => .(sec (mod sec day:yo))
194− =+ hor=(div sec hor:yo)
195− => .(sec (mod sec hor:yo))
196− =+ mit=(div sec mit:yo)
197− => .(sec (mod sec mit:yo))
198− [day hor mit sec fan]
199−```
200−
201−#### Examples
202−
203−```
204− > (yell ~2014.3.20..05.42.53..7456)
205− [d=106.751.991.820.094 h=5 m=42 s=53 f=~[0x7456]]
206−
207− > (yell ~2014.6.9..19.09.40..8b66)
208− [d=106.751.991.820.175 h=19 m=9 s=40 f=~[0x8b66]]
209−
210− > (yell ~1776.7.4)
211− [d=106.751.991.733.273 h=0 m=0 s=0 f=~]
212−```
213−
214−---
215−### `++yelp`
216−
217−Leap-week?
218−
219−Determines whether a year contains an ISO 8601 leap-week. Produces a flag.
220−
221−#### Accepts
222−
223−`yer` is an unsigned decimal.
224−
225−#### Produces
226−
227−A flag.
228−
229−#### Source
230−
231−```hoon
232− ++ yelp
233− |= yer=@ud ^- ?
234− &(=(0 (mod yer 4)) |(!=(0 (mod yer 100)) =(0 (mod yer 400))))
235−```
236−
237−#### Examples
238−
239−```
240− > (yelp 2.014)
241− %.n
242−
243− > (yelp 2.008)
244− %.y
245−
246− > (yelp 0)
247− %.y
248−
249− > (yelp 14.011)
250− %.n
251−```
252−
253−---
254−### `++yore`
255−
256−Date from atomic date
257−
258−Produces a `date` from a `@d`.
259−
260−#### Accepts
261−
262−`now` is a time atom, `@d`.
263−
264−#### Produces
265−
266−A `date`.
267−
268−#### Source
269−
270−```hoon
271− ++ yore
272− |= now=@da
273− ^- date
274− =+ rip=(yell now)
275− =+ ger=(yall d.rip)
276− :- ?: (gth y.ger 292.277.024.400)
277− [a=& y=(sub y.ger 292.277.024.400)]
278− [a=| y=+((sub 292.277.024.400 y.ger))]
279− [m.ger d.ger h.rip m.rip s.rip f.rip]
280−```
281−
282−#### Examples
283−
284−```
285− > (yore ~2014.6.6..21.09.15..0a16)
286− [[a=%.y y=2.014] m=6 t=[d=6 h=21 m=9 s=15 f=~[0xa16]]]
287−```
288−
289−---
290−### `++yule`
291−
292−Daily time to time atom
293−
294−Accepts a `tarp`, a parsed daily time, and produces a time atom,
295−`@d`.
296−
297−#### Accepts
298−
299−`rip` is a `tarp`.
300−
301−#### Produces
302−
303−A time atom, `@d`.
304−
305−#### Source
306−
307−```hoon
308− ++ yule :: time atom
309− |= rip=tarp
310− ^- @d
311− =+ ^= sec ;: add
312− (mul d.rip day:yo)
313− (mul h.rip hor:yo)
314− (mul m.rip mit:yo)
315− s.rip
316− ==
317− =+ ^= fac =+ muc=4
318− |- ^- @
319− ?~ f.rip
320− 0
321− => .(muc (dec muc))
322− (add (lsh 4 muc i.f.rip) $(f.rip t.f.rip))
323− (con (lsh 6 1 sec) fac)
324− ::
325−```
326−
327−#### Examples
328−
329−```
330− > =murica (yell ~1776.7.4)
331−
332− > murica
333− [d=106.751.991.733.273 h=0 m=0 s=0 f=~]
334−
335− > (yule murica)
336− 0x8000000b62aaf5800000000000000000
337−
338− > `@da`(yule murica)
339− ~1776.7.4
340−
341− > `@da`(yule (yell ~2014.3.20..05.42.53..7456))
342− ~2014.3.20..05.42.53..7456
343−
344− > `tarp`[31 12 30 0 ~]
345− [d=31 h=12 m=30 s=0 f=~]
346−
347− > `@dr`(yule `tarp`[31 12 30 0 ~])
348− ~d31.h12.m30
349−```
350−
351−---
352−### `++yo`
353−
354−Time constants core
355−
356−Core whose arms contain constants for interacting with earth time.
357−
358−#### Source
359−
360−```hoon
361− ++ yo
362−```
363−
364−---
365−### `++cet:yo`
366−
367−Days in a century
368−
369−Derived by multiplying the number of days in a year
370−(365) by the number of years in a century (100), then adding the number
371−days from leap-years in a century (24).
372−
373−#### Produces
374−
375−An atom.
376−
377−#### Source
378−
379−```hoon
380− |% ++ cet 36.524
381−```
382−
383−#### Examples
384−
385−```
386− > cet:yo
387− 36.524
388−
389− > (add 365 cet:yo)
390− 36.889
391−
392− > (sub (add 24 (mul 100 365)) cet:yo)
393− 0
394−```
395−
396−---
397−### `++day:yo`
398−
399−Seconds in day
400−
401−The number of seconds in a day.
402−
403−#### Produces
404−
405−An atom.
406−
407−#### Source
408−
409−```hoon
410− ++ day 86.400
411−```
412−
413−#### Examples
414−
415−```
416− > day:yo
417− 86.400
418−
419− > (add 60 day:yo)
420− 86.460
421−```
422−
423−---
424−### `++era:yo`
425−
426−Leap-year period
427−
428−The number of days in a 400-year period, arrived at by multiplying `cet` by four
429−and adding one. This is done because every 400 years, there is a leap-year where
430−there would otherwise not be.
431−
432−#### Produces
433−
434−An atom.
435−
436−#### Source
437−
438−```hoon
439− ++ era 146.097
440−```
441−
442−#### Examples
443−
444−```
445− > era:yo
446− 146.097
447−
448− > (sub era:yo (mul 4 cet:yo))
449− 1
450−```
451−
452−#### Discussion
453−
454−A year is a leap-year if:
455−
456−- it's divisible by 4;
457−- **unless** it's divisible by 100;
458−- **or** if it's divisible by 400.
459−
460−---
461−### `++hor:yo`
462−
463−Seconds in hour
464−
465−The number of seconds in an hour. Derived by multiplying the number of
466−seconds in a minute by the minutes in an hour.
467−
468−#### Produces
469−
470−An atom.
471−
472−#### Source
473−
474−```hoon
475− ++ hor 3.600
476−```
477−
478−#### Examples
479−
480−```
481− > hor:yo
482− 3.600
483−
484− > (div hor:yo 60)
485− 60
486−```
487−
488−---
489−### `++jes:yo`
490−
491−Maximum 64-bit timestamp
492−
493−This is the number of days (starting from 1970) that can be represented in a
494−64-bit timestamp. Derived by multiplying `era:yo` by 730,692,561.
495−
496−#### Produces
497−
498−An atom.
499−
500−#### Source
501−
502−```hoon
503− ++ jes 106.751.991.084.417
504−```
505−
506−#### Examples
507−
508−```
509− > jes:yo
510− 106.751.991.084.417
511−```
512−
513−#### Discussion
514−
515−The date is December 4, 292,277,026,596.
516−
517−---
518−### `++mit:yo`
519−
520−Seconds in minute
521−
522−The number of seconds in a minute.
523−
524−#### Produces
525−
526−An atom.
527−
528−#### Source
529−
530−```hoon
531− ++ mit 60
532−```
533−
534−#### Examples
535−
536−```
537− > mit:yo
538− 60
539−```
540−
541−---
542−### `++moh:yo`
543−
544−Days in month
545−
546−The days in each month of the Gregorian common year. A list of unsigned
547−decimal atoms (Either 28, 30, or 31) denoting the number of days in the
548−month at the year at that index.
549−
550−#### Produces
551−
552−A `list` of `@ud`
553−
554−#### Source
555−
556−```hoon
557− ++ moh `(list @ud)`[31 28 31 30 31 30 31 31 30 31 30 31 ~]
558−```
559−
560−#### Examples
561−
562−```
563− > moh:yo
564− ~[31 28 31 30 31 30 31 31 30 31 30 31]
565−
566− > (snag 4 moh:yo)
567− 31
568−```
569−
570−---
571−### `++moy:yo`
572−
573−Days in months of leap-year
574−
575−The days in each month of the Gregorian leap-year. A list of unsigned
576−decimal atoms (Either 29, 30, or 31) denoting the number of days in the
577−month at the leap-year at that index.
578−
579−#### Produces
580−
581−A `list` of `@ud`.
582−
583−#### Source
584−
585−```hoon
586− ++ moy `(list @ud)`[31 29 31 30 31 30 31 31 30 31 30 31 ~]
587−```
588−
589−#### Examples
590−
591−```
592− > moy:yo
593− ~[31 29 31 30 31 30 31 31 30 31 30 31]
594−
595− > (snag 1 moy:yo)
596− 29
597−```
598−
599−---
600−### `++qad:yo`
601−
602−Seconds in 4 years
603−
604−The number of seconds in four years. Derived by adding one second to the
605−number of seconds in four years.
606−
607−#### Produces
608−
609−An atom.
610−
611−#### Source
612−
613−```hoon
614− ++ qad 126.144.001
615−```
616−
617−#### Examples
618−
619−```
620− > qad:yo
621− 126.144.001
622−```
623−
624−---
625−### `++yer:yo`
626−
627−Seconds in year
628−
629−The number of seconds in a year. Derived by multiplying the number of
630−seconds in a day by 365.
631−
632−#### Produces
633−
634−An atom.
635−
636−#### Source
637−
638−```hoon
639− ++ yer 31.536.000
640−```
641−
642−#### Examples
643−
644−```
645− > yer:yo
646− 31.536.000
647−```
648−
649−---
reference/library/3d.md+15−15
@@ -21,7 +21,7 @@ An atom.
2121
2222#### Source
2323
24−```hoon
24+```reference
2525 ++ shad |=(ruz=@ (shax (shax ruz)))
2626```
2727
@@ -49,7 +49,7 @@ first and last halves of the 256-bit salted hash `shas`.
4949
5050#### Source
5151
52−```hoon
52+```reference
5353 ++ shaf :: half sha-256
5454 |= [sal=@ ruz=@]
5555 =+ haz=(shas sal ruz)
@@ -88,7 +88,7 @@ An atom.
8888
8989#### Source
9090
91−```hoon
91+```reference
9292 ++ shal
9393 ~/ %shal
9494 |= [len=@ ruz=@] ^- @
@@ -243,7 +243,7 @@ An atom.
243243
244244#### Source
245245
246−```hoon
246+```reference
247247 ++ sham
248248 |= yux=* ^- @uvH ^- @
249249 ?@ yux
@@ -279,7 +279,7 @@ An atom.
279279
280280#### Source
281281
282−```hoon
282+```reference
283283 ++ shan
284284 |= ruz=@
285285 =+ [few==>(fe .(a 5)) wac=|=([a=@ b=@] (cut 5 [a 1] b))]
@@ -375,7 +375,7 @@ of that logical operation is then itself hashed with SHA-256.
375375
376376#### Source
377377
378−```hoon
378+```reference
379379 ++ shas
380380 |= [sal=@ ruz=@]
381381 (shax (mix sal (shax ruz)))
@@ -412,7 +412,7 @@ An atom.
412412
413413#### Source
414414
415−```hoon
415+```reference
416416 ++ shaw
417417 |= [sal=@ len=@ ruz=@]
418418 (~(raw og (shas sal (mix len ruz))) len)
@@ -437,7 +437,7 @@ Produces an atom by hashing an atom `ruz` with SHA-256.
437437
438438#### Sources
439439
440−```hoon
440+```reference
441441 ++ shax
442442 ~/ %shax
443443 |= ruz=@ ^- @
@@ -469,7 +469,7 @@ the byte-length of the theoretical buffer represented by the atom.
469469
470470#### Source
471471
472−```hoon
472+```reference
473473 ++ shay
474474 ~/ %shay
475475 |= [len=@u ruz=@] ^- @
@@ -594,7 +594,7 @@ An atom.
594594
595595#### Source
596596
597−```hoon
597+```reference
598598 ++ shaz
599599 |= ruz=@ ^- @
600600 (shal [(met 3 ruz) ruz])
@@ -626,7 +626,7 @@ A core.
626626
627627#### Source
628628
629−```hoon
629+```reference
630630 ++ og
631631 ~/ %og
632632 |_ a=@
@@ -663,7 +663,7 @@ An atom.
663663
664664#### Source
665665
666−```hoon
666+```reference
667667 ++ rad
668668 |= b=@ ^- @
669669 =+ c=(raw (met 0 b))
@@ -705,7 +705,7 @@ A cell.
705705
706706#### Source
707707
708−```hoon
708+```reference
709709 ++ rads
710710 |= b=@
711711 =+ r=(rad b)
@@ -748,7 +748,7 @@ An atom.
748748
749749#### Source
750750
751−```hoon
751+```reference
752752 ++ raw
753753 ~/ %raw
754754 |= b=@ ^- @
@@ -791,7 +791,7 @@ parent core with `(raw b)`.
791791
792792#### Source
793793
794−```hoon
794+```reference
795795 ++ raws
796796 |= b=@
797797 =+ r=(raw b)
reference/library/3e.mddeleted−9
@@ -1,9 +0,0 @@
1−+++
2−title = "3e: AES encryption (Removed)"
3−weight = 25
4−template = "doc.html"
5−aliases = ["/docs/reference/library/3e"]
6−+++
7−The standard-library functions in this section have been removed.
8−
9−---
reference/library/3f.md+17−17
@@ -13,7 +13,7 @@ Used in the `@p` phonetic base.
1313
1414#### Source
1515
16−```hoon
16+```reference
1717 ++ un
1818 |%
1919```
@@ -37,7 +37,7 @@ An atom.
3737
3838#### Source
3939
40−```hoon
40+```reference
4141 ++ wren
4242 |= pyn=@ ^- @
4343 =+ len=(met 3 pyn)
@@ -89,7 +89,7 @@ An atom.
8989
9090#### Source
9191
92−```hoon
92+```reference
9393 ++ wred
9494 |= cry=@ ^- @
9595 =+ len=(met 3 cry)
@@ -142,7 +142,7 @@ An atom.
142142
143143#### Source
144144
145−```hoon
145+```reference
146146 ++ xafo |=([a=@ b=@] +((mod (add (dec b) a) 255)))
147147```
148148
@@ -179,7 +179,7 @@ An atom.
179179
180180#### Source
181181
182−```hoon
182+```reference
183183 ++ xaro |=([a=@ b=@] +((mod (add (dec b) (sub 255 (mod a 255))) 255)))
184184```
185185
@@ -214,7 +214,7 @@ An atom.
214214
215215#### Source
216216
217−```hoon
217+```reference
218218 ++ zaft
219219 |= a=@D
220220 =+ ^= b
@@ -266,7 +266,7 @@ An atom.
266266
267267#### Source
268268
269−```hoon
269+```reference
270270 ++ zart :: reverse 255-sbox
271271 |= a=@D
272272 =+ ^= b
@@ -316,7 +316,7 @@ An atom.
316316
317317#### Source
318318
319−```hoon
319+```reference
320320 ++ zyft :: forward 256-sbox
321321 |= a=@D
322322 =+ ^= b
@@ -369,7 +369,7 @@ An atom.
369369
370370#### Source
371371
372−```hoon
372+```reference
373373 ++ zyrt :: reverse 256-sbox
374374 |= a=@D
375375 =+ ^= b
@@ -408,7 +408,7 @@ An atom.
408408
409409Reversible scrambling, v2
410410
411−```hoon
411+```reference
412412 ++ ob
413413 |%
414414```
@@ -435,7 +435,7 @@ An atom.
435435
436436#### Source
437437
438−```hoon
438+```reference
439439 ++ feen
440440 |= pyn=@ ^- @
441441 ?: &((gte pyn 0x1.0000) (lte pyn 0xffff.ffff))
@@ -485,7 +485,7 @@ An atom.
485485
486486#### Source
487487
488−```hoon
488+```reference
489489 ++ fend
490490 |= cry=@ ^- @
491491 ?: &((gte cry 0x1.0000) (lte cry 0xffff.ffff))
@@ -538,7 +538,7 @@ An atom.
538538
539539#### Source
540540
541−```hoon
541+```reference
542542 ++ fice :: adapted from
543543 |= nor=@ :: black and rogaway
544544 ^- @ :: "ciphers with
@@ -581,7 +581,7 @@ An atom.
581581
582582#### Source
583583
584−```hoon
584+```reference
585585 ++ teil :: reverse ++fice
586586 |= vip=@
587587 ^- @
@@ -627,7 +627,7 @@ A cell of two atoms.
627627
628628#### Source
629629
630−```hoon
630+```reference
631631 ++ rynd
632632 |= [n=@ l=@ r=@]
633633 ^- [@ @]
@@ -669,7 +669,7 @@ A cell of two atoms.
669669
670670#### Source
671671
672−```hoon
672+```reference
673673 ++ rund
674674 |= [n=@ l=@ r=@]
675675 ^- [@ @]
@@ -702,7 +702,7 @@ A list of atoms of aura `@ux` (hexadecimal).
702702
703703#### Source
704704
705−```hoon
705+```reference
706706 ++ raku
707707 ^- (list @ux)
708708 :~ 0xb76d.5eed
reference/library/3g.md+13−13
@@ -14,7 +14,7 @@ and printed using `++so` and `++co` cores.
1414
1515#### Source
1616
17−```hoon
17+```reference
1818 ++ coin $% [$$ p=dime]
1919 [$blob p=*]
2020 [$many p=(list coin)]
@@ -59,7 +59,7 @@ to parse atoms of specific auras.
5959
6060#### Source
6161
62−```hoon
62+```reference
6363 ++ dime [p=@ta q=@]
6464```
6565
@@ -79,7 +79,7 @@ Optional result `p` and parsing continuation `q`.
7979
8080#### Source
8181
82−```hoon
82+```reference
8383 ++ hair [p=@ud q=@ud]
8484```
8585
@@ -107,7 +107,7 @@ A pair of two `@ud` used in parsing indicating line and column number.
107107
108108#### Source
109109
110−```hoon
110+```reference
111111 ++ hair [p=@ud q=@ud]
112112```
113113
@@ -136,7 +136,7 @@ Generates an `++edge` with a parsed result set to a specific type.
136136
137137#### Source
138138
139−```hoon
139+```reference
140140 ++ like |* a=gate
141141 |= b=_`*`[(hair) ~]
142142 :- p=(hair -.b)
@@ -170,7 +170,7 @@ Indicates parsing position `p`, and remaining text to be parsed `q`.
170170
171171#### Source
172172
173−```hoon
173+```reference
174174 ++ nail [p=hair q=tape]
175175```
176176
@@ -190,7 +190,7 @@ A list of `++knot`s. `++knot` is another name for `@ta`.
190190
191191#### Source
192192
193−```hoon
193+```reference
194194 ++ path (list knot)
195195```
196196
@@ -215,7 +215,7 @@ stack traces.
215215
216216#### Source
217217
218−```hoon
218+```reference
219219 ++ pint [p=[p=@ q=@] q=[p=@ q=@]]
220220```
221221
@@ -240,7 +240,7 @@ An empty parsing rule, but used to check that parsing rules match this with `_`.
240240
241241#### Source
242242
243−```hoon
243+```reference
244244 ++ rule _|=(nail *edge)
245245```
246246
@@ -260,7 +260,7 @@ The stack trace that is printed after crashing.
260260
261261#### Source
262262
263−```hoon
263+```reference
264264 ++ spot [p=path q=pint]
265265```
266266
@@ -283,7 +283,7 @@ or failure with an error report (`%2`).
283283
284284#### Source
285285
286−```hoon
286+```reference
287287 ++ tone $% [$0 p=*] :: success
288288 [$1 p=(list)] :: blocks
289289 [$2 p=(list [@ta *])] :: error report
@@ -331,7 +331,7 @@ or failure with a stack trace (`%2`).
331331
332332#### Source
333333
334−```hoon
334+```reference
335335 ++ toon $% [$0 p=*] :: success
336336 [$1 p=(list)] :: blocks
337337 [$2 p=(list tank)] :: stack trace
@@ -357,7 +357,7 @@ Pull result out of a `++edge`, or crash if there's no result.
357357
358358#### Source
359359
360−```hoon
360+```reference
361361 ++ wonk |*(veq=edge ?~(q.veq !! p.u.q.veq))
362362```
363363
reference/library/4a.mddeleted−217
@@ -1,217 +0,0 @@
1−+++
2−title = "4a: Exotic Bases"
3−weight = 28
4−template = "doc.html"
5−aliases = ["/docs/reference/library/4a"]
6−+++
7−### `++po`
8−
9−Phonetic base
10−
11−Container core for providing phonetic syllables and name generators for the
12−Urbit naming system. The two faces, `sis` and `dex`, are available to the
13−contained arms.
14−
15−#### Source
16−
17−```hoon
18− ~/ %po
19− =+ :- ^= sis :: prefix syllables
20− 'dozmarbinwansamlitsighidfidlissogdirwacsabwissib\
21− /rigsoldopmodfoglidhopdardorlorhodfolrintogsilmir\
22− /holpaslacrovlivdalsatlibtabhanticpidtorbolfosdot\
23− /losdilforpilramtirwintadbicdifrocwidbisdasmidlop\
24− /rilnardapmolsanlocnovsitnidtipsicropwitnatpanmin\
25− /ritpodmottamtolsavposnapnopsomfinfonbanmorworsip\
26− /ronnorbotwicsocwatdolmagpicdavbidbaltimtasmallig\
27− /sivtagpadsaldivdactansidfabtarmonranniswolmispal\
28− /lasdismaprabtobrollatlonnodnavfignomnibpagsopral\
29− /bilhaddocridmocpacravripfaltodtiltinhapmicfanpat\
30− /taclabmogsimsonpinlomrictapfirhasbosbatpochactid\
31− /havsaplindibhosdabbitbarracparloddosbortochilmac\
32− /tomdigfilfasmithobharmighinradmashalraglagfadtop\
33− /mophabnilnosmilfopfamdatnoldinhatnacrisfotribhoc\
34− /nimlarfitwalrapsarnalmoslandondanladdovrivbacpol\
35− /laptalpitnambonrostonfodponsovnocsorlavmatmipfip'
36− ^= dex :: suffix syllables
37− 'zodnecbudwessevpersutletfulpensytdurwepserwylsun\
38− /rypsyxdyrnuphebpeglupdepdysputlughecryttyvsydnex\
39− /lunmeplutseppesdelsulpedtemledtulmetwenbynhexfeb\
40− /pyldulhetmevruttylwydtepbesdexsefwycburderneppur\
41− /rysrebdennutsubpetrulsynregtydsupsemwynrecmegnet\
42− /secmulnymtevwebsummutnyxrextebfushepbenmuswyxsym\
43− /selrucdecwexsyrwetdylmynmesdetbetbeltuxtugmyrpel\
44− /syptermebsetdutdegtexsurfeltudnuxruxrenwytnubmed\
45− /lytdusnebrumtynseglyxpunresredfunrevrefmectedrus\
46− /bexlebduxrynnumpyxrygryxfeptyrtustyclegnemfermer\
47− /tenlusnussyltecmexpubrymtucfyllepdebbermughuttun\
48− /bylsudpemdevlurdefbusbeprunmelpexdytbyttyplevmyl\
49− /wedducfurfexnulluclennerlexrupnedlecrydlydfenwel\
50− /nydhusrelrudneshesfetdesretdunlernyrsebhulryllud\
51− /remlysfynwerrycsugnysnyllyndyndemluxfedsedbecmun\
52− /lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes'
53− |%
54−```
55−
56−---
57−### `++ind:po`
58−
59−Parse suffix
60−
61−Produces the byte of the right-hand syllable `a`.
62−
63−#### Accepts
64−
65−`a` is an atom.
66−
67−#### Produces
68−
69−A `unit`.
70−
71−#### Source
72−
73−```hoon
74− ++ ind ~/ %ind
75− |= a=@tas
76− =+ b=0
77− |- ^- (unit @)
78− ?:(=(256 b) ~ ?:(=(a (tod b)) [~ b] $(b +(b))))
79−```
80−
81−#### Examples
82−
83−```
84− > (ind:po 'zod')
85− [~ u=0]
86−
87− > (ind:po 'zam')
88− ~
89−
90− > (ind:po 'del')
91− [~ u=37]
92−```
93−
94−---
95−### `++ins:po`
96−
97−Parse prefix
98−
99−Produces the byte of the left-hand phonetic syllable `a`.
100−
101−#### Accepts
102−
103−`a` is an atom.
104−
105−#### Produces
106−
107−A `unit` of an atom.
108−
109−#### Source
110−
111−```hoon
112− ++ ins ~/ %ins
113− |= a=@tas
114− =+ b=0
115− |- ^- (unit @)
116− ?:(=(256 b) ~ ?:(=(a (tos b)) [~ b] $(b +(b))))
117−```
118−
119−#### Examples
120−
121−```
122− > (ins:po 'mar')
123− [~ u=1]
124−
125− > (ins:po 'son')
126− [~ u=164]
127−
128− > (ins:po 'pit')
129− [~ u=242]
130−
131− > (ins:po 'pok')
132− ~
133−```
134−
135−---
136−### `++tod:po`
137−
138−Fetch suffix
139−
140−Produces the phonetic suffix syllable from index `a` within `dex` as an atom.
141−
142−#### Accepts
143−
144−`a` is an atom
145−
146−#### Produces
147−
148−An atom.
149−
150−#### Source
151−
152−```hoon
153− ++ tod ~/ %tod
154− |=(a=@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] dex)))
155−```
156−
157−#### Examples
158−
159−```
160− > `@t`(tod:po 1)
161− 'nec'
162−
163− > `@t`(tod:po 98)
164− 'dec'
165−
166− > `@t`(tod:po 0)
167− 'zod'
168−
169− > `@t`(tod:po 150)
170− 'ryg'
171−
172− > `@t`(tod:po 255)
173− 'fes'
174−
175− > `@t`(tod:po 256)
176− ! exit
177−```
178−
179−---
180−### `++tos:po`
181−
182−Fetch prefix
183−
184−Produces the phonetic prefix syllable from index `a` within `sis` as an atom.
185−
186−#### Accepts
187−
188−`a` is an atom.
189−
190−#### Produces
191−
192−An atom.
193−
194−#### Source
195−
196−```hoon
197− ++ tos ~/ %tos
198− |=(a=@ ?>((lth a 256) (cut 3 [(mul 3 a) 3] sis)))
199−```
200−
201−#### Examples
202−
203−```
204− > `@t`(tos:po 0)
205− 'doz'
206−
207− > `@t`(tos:po 120)
208− 'fab'
209−
210− > `@t`(tos:po 43)
211− 'pid'
212−
213− > `@t`(tos:po 253)
214− 'mat'
215−```
216−
217−---
reference/library/4b.mddeleted−994
@@ -1,994 +0,0 @@
1−+++
2−title = "4b: Text Processing"
3−weight = 29
4−template = "doc.html"
5−aliases = ["/docs/reference/library/4b"]
6−+++
7−### `++at`
8−
9−```hoon
10− ++ at
11− |_ a=@
12−```
13−
14−XX document
15−
16−
17−
18−### `++r:at`
19−
20−```hoon
21− ++ r
22− ?: ?& (gte (met 3 a) 2)
23− |-
24− ?: =(0 a)
25− &
26− =+ vis=(end 3 1 a)
27− ?& ?|(=('-' vis) ?&((gte vis 'a') (lte vis 'z')))
28− $(a (rsh 3 1 a))
29− ==
30− ==
31− rtam
32− ?: (lte (met 3 a) 2)
33− rud
34− rux
35−```
36−
37−
38−XX document
39−
40−### `++rf:at`
41−
42−```hoon
43− ++ rf `tape`[?-(a $& '&', $| '|', * !!) ~]
44−```
45−
46−
47−XX document
48−
49−### `++rn:at`
50−
51−```hoon
52− ++ rn `tape`[?>(=(0 a) '~') ~]
53−```
54−
55−XX document
56−
57−### `++rt:at`
58−
59−```hoon
60− ++ rt `tape`['\'' (weld (mesc (trip a)) `tape`['\'' ~])]
61−```
62−
63−XX document
64−
65−### `++rta:at`
66−
67−```hoon
68− ++ rta rt
69−```
70−
71−XX document
72−
73−### `++rtam:at`
74−
75−```hoon
76− ++ rtam `tape`['%' (trip a)]
77−```
78−
79−XX document
80−
81−### `++rub:at`
82−
83−```hoon
84− ++ rub `tape`['0' 'b' (rum 2 ~ |=(b/@ (add '0' b)))]
85−```
86−
87−XX document
88−
89−### `++rud:at`
90−
91−```hoon
92− ++ rud (rum 10 ~ |=(b/@ (add '0' b)))
93−```
94−
95−XX document
96−
97−### `++rum:at`
98−
99−```hoon
100− ++ rum
101− |= {b/@ c/tape d/$-(@ @)}
102− ^- tape
103− ?: =(0 a)
104− [(d 0) c]
105− =+ e=0
106− |- ^- tape
107− ?: =(0 a)
108− c
109− =+ f=&(!=(0 e) =(0 (mod e ?:(=(10 b) 3 4))))
110− %= $
111− a (div a b)
112− c [(d (mod a b)) ?:(f [?:(=(10 b) ',' '-') c] c)]
113− e +(e)
114− ==
115− ::
116−```
117−
118−XX document
119−
120−### `++rup:at`
121−
122−```hoon
123− ++ rup
124− =+ b=(met 3 a)
125− ^- tape
126− :- '-'
127− |- ^- tape
128− ?: (gth (met 5 a) 1)
129− %+ weld
130− $(a (rsh 5 1 a), b (sub b 4))
131− `tape`['-' '-' $(a (end 5 1 a), b 4)]
132− ?: =(0 b)
133− ['~' ~]
134− ?: (lte b 1)
135− (trip (tos:po a))
136− |- ^- tape
137− ?: =(2 b)
138− =+ c=(rsh 3 1 a)
139− =+ d=(end 3 1 a)
140− (weld (trip (tod:po c)) (trip (tos:po (mix c d))))
141− =+ c=(rsh 3 2 a)
142− =+ d=(end 3 2 a)
143− (weld ^$(a c, b (met 3 c)) `tape`['-' $(a (mix c d), b 2)])
144− ::
145−```
146−
147−XX document
148−
149−### `++ruv:at`
150−
151−```hoon
152− ++ ruv
153− ^- tape
154− :+ '0'
155− 'v'
156− %^ rum
157− 64
158− ~
159− |= b/@
160− ?: =(63 b)
161− '+'
162− ?: =(62 b)
163− '-'
164− ?:((lth b 26) (add 65 b) ?:((lth b 52) (add 71 b) (sub b 4)))
165− ::
166−```
167−
168−XX document
169−
170−### `++rux:at`
171−
172−```hoon
173− ++ rux `tape`['0' 'x' (rum 16 ~ |=(b/@ (add b ?:((lth b 10) 48 87))))]
174− --
175− :::::::::::::::::::::::::::::::::::::::::::::::::::::: ::
176−```
177−
178−XX document
179−
180−---
181−
182−
183−---
184−
185−### `++cass`
186−
187−To lowercase
188−
189−Turn all occurences of uppercase letters in any `++tape` into lowercase
190−letters. Returns a `++tape`.
191−
192−#### Accepts
193−
194−`vib` is a `++tape`.
195−
196−#### Produces
197−
198−A `++tape`.
199−
200−#### Source
201−
202−```hoon
203− ++ cass :: lowercase
204− |= vib/tape
205− ^- tape
206− (turn vib |=(a/@ ?.(&((gte a 'A') (lte a 'Z')) a (add 32 a))))
207−```
208−
209−#### Examples
210−
211−```
212− > (cass "JOHN DOE")
213− "john doe"
214−
215− > (cass "abc ABC 123 !@#")
216− "abc abc 123 !@#"
217−
218− > (cass "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsQqRrVvWwXxYyZz")
219− "aabbccddeeffgghhiijjkkllmmnnooppqqrrssqqrrvvwwxxyyzz"
220−```
221−
222−---
223−### `++crip`
224−
225−Tape to cord
226−
227−Produce a `++cord` from a `++tape`.
228−
229−#### Accepts
230−
231−`a` is a `++tape`.
232−
233−#### Produces
234−
235−A `++cord`.
236−
237−#### Source
238−
239−```hoon
240− ++ crip |=(a=tape `@t`(rap 3 a)) :: tape to cord
241−```
242−
243−#### Examples
244−
245−```
246− > (crip "john doe")
247− 'john doe'
248−
249− > (crip "abc 123 !@#")
250− 'abc 123 !@#'
251−
252− > `@ud`(crip "abc")
253− 6.513.249
254−```
255−
256−---
257−### `++cuss`
258−
259−To uppercase
260−
261−Turn all occurences of lowercase letters in any `++tape` into uppercase
262−letters. Returns a `++tape`.
263−
264−#### Accepts
265−
266−`vib` is a `++tape`.
267−
268−#### Produces
269−
270−A `++tape`.
271−
272−#### Source
273−
274−```hoon
275− ++ cuss :: uppercase
276− |= vib/tape
277− ^- tape
278− (turn vib |=(a/@ ?.(&((gte a 'a') (lte a 'z')) a (sub a 32))))
279−```
280−
281−#### Examples
282−
283−```
284− > (cuss "john doe")
285− "JOHN DOE"
286−
287− > (cuss "abc ABC 123 !@#")
288− "ABC ABC 123 !@#"
289−
290− > (cuss "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsQqRrVvWwXxYyZz")
291− "AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSQQRRVVWWXXYYZZ"
292−```
293−
294−---
295−### `++mesc`
296−
297−Escape special chars
298−
299−Escape special characters, used in `++show`.
300−
301−#### Accepts
302−
303−`vib` is a `++tape`.
304−
305−#### Produces
306−
307−A `++tape`.
308−
309−#### Source
310−
311−```hoon
312− ++ mesc :: ctrl code escape
313− |= vib/tape
314− ^- tape
315− ?~ vib
316− ~
317− ?: =('\\' i.vib)
318− ['\\' '\\' $(vib t.vib)]
319− ?: ?|((gth i.vib 126) (lth i.vib 32) =(`@`39 i.vib))
320− ['\\' (welp ~(rux at i.vib) '/' $(vib t.vib))]
321− [i.vib $(vib t.vib)]
322−```
323−
324−#### Examples
325−
326−```
327− > (mesc "ham lus")
328− "ham lus"
329− > (mesc "bas\\hur")
330− "bas\\\\hur"
331− > (mesc "as'saß")
332− "as\0x27/sa\0xc3/\0x9f/"
333−```
334−
335−
336−---
337−### `++runt`
338−
339−Prepend `n` times
340−
341−Add `a` repetitions of character `b` to the head of `++tape` `c`.
342−
343−#### Accepts
344−
345−`a` and `b` are atoms.
346−
347−`c` is a `++tape`.
348−
349−#### Produces
350−
351−A `++tape`.
352−
353−#### Source
354−
355−```hoon
356− ++ runt :: prepend repeatedly
357− |= [[a/@ b/@] c/tape]
358− ^- tape
359− ?: =(0 a)
360− c
361− [b $(a (dec a))]
362− ::
363−```
364−
365−#### Examples
366−
367−```
368− > (runt [2 '/'] "ham")
369− "//ham"
370− > (runt [10 'a'] "")
371− "aaaaaaaaaa"
372−```
373−
374−
375−---
376−### `++sand`
377−
378−Soft-cast by odor
379−
380−Soft-cast validity by odor.
381−
382−#### Accepts
383−
384−`a` is a `++span` (`@ta`).
385−
386−`b` is an atom.
387−
388−#### Produces
389−
390−A `(unit @)`.
391−
392−#### Source
393−
394−```hoon
395− ++ sand :: atom sanity
396− |= a/@ta
397− |= b/@ ^- (unit @)
398− ?.(((sane a) b) ~ [~ b])
399− ::
400−```
401−
402−#### Examples
403−
404−```
405− > `(unit @ta)`((sand %ta) 'sym-som')
406− [~ ~.sym-som]
407− > `(unit @ta)`((sand %ta) 'err!')
408− ~
409−```
410−
411−
412−---
413−### `++sane`
414−
415−Check odor validity
416−
417−Check validity by odor. Produces a gate.
418−
419−#### Accepts
420−
421−`a` is a `++span` (`@ta`).
422−
423−`b` is an atom.
424−
425−#### Produces
426−
427−A boolean.
428−
429−#### Source
430−
431−```hoon
432− ++ sane :: atom sanity
433− |= a/@ta
434− |= b/@ ^- ?
435− ?. =(%t (end 3 1 a))
436− ~|(%sane-stub !!)
437− =+ [inx=0 len=(met 3 b)]
438− ?: =(%tas a)
439− |- ^- ?
440− ?: =(inx len) &
441− =+ cur=(cut 3 [inx 1] b)
442− ?& ?| &((gte cur 'a') (lte cur 'z'))
443− &(=('-' cur) !=(0 inx) !=(len inx))
444− &(&((gte cur '0') (lte cur '9')) !=(0 inx))
445− ==
446− $(inx +(inx))
447− ==
448− ?: =(%ta a)
449− |- ^- ?
450− ?: =(inx len) &
451− =+ cur=(cut 3 [inx 1] b)
452− ?& ?| &((gte cur 'a') (lte cur 'z'))
453− &((gte cur '0') (lte cur '9'))
454− |(=('-' cur) =('~' cur) =('_' cur) =('.' cur))
455− ==
456− $(inx +(inx))
457− ==
458− |- ^- ?
459− ?: =(0 b) &
460− =+ cur=(end 3 1 b)
461− ?: &((lth cur 32) !=(10 cur)) |
462− =+ len=(teff cur)
463− ?& |(=(1 len) =+(i=1 |-(|(=(i len) &((gte (cut 3 [i 1] b) 128) $(i +(i)))))))
464− $(b (rsh 3 len b))
465− ==
466− ::
467−```
468−
469−#### Examples
470−
471−```
472− > ((sane %tas) %mol)
473− %.y
474− > ((sane %tas) 'lam')
475− %.y
476− > ((sane %tas) 'more ace')
477− %.n
478−```
479−
480−
481−---
482−### `++teff`
483−
484−UTF8 Length
485−
486−Produces the number of utf8 bytes.
487−
488−#### Accepts
489−
490−`a` is a `@t`.
491−
492−#### Produces
493−
494−An atom.
495−
496−#### Source
497−
498−```hoon
499− |= a/@t ^- @
500− =+ b=(end 3 1 a)
501− ~| %bad-utf8
502− ?: =(0 b)
503− ?>(=(`@`0 a) 0)
504− ?> |((gte b 32) =(10 b))
505− ?:((lte b 127) 1 ?:((lte b 223) 2 ?:((lte b 239) 3 4)))
506−```
507−
508−#### Examples
509−
510−```
511− > (teff 'a')
512− 1
513− > (teff 'ß')
514− 2
515−```
516−
517−
518−---
519−### `++trim`
520−
521−Tape split
522−
523−Split first `a` characters off `++tape` `b`.
524−
525−#### Accepts
526−
527−`a` is an atom.
528−
529−`b` is a `++tape`.
530−
531−#### Produces
532−
533−A cell of `++tape`s, `p` and `q`.
534−
535−#### Source
536−
537−```hoon
538− ++ trim :: 31-bit nonzero
539− |= key/@
540− =+ syd=0xcafe.babe
541− |- ^- @
542− =+ haz=(spec syd key)
543− =+ ham=(mix (rsh 0 31 haz) (end 0 31 haz))
544− ?.(=(0 ham) ham $(syd +(syd)))
545− --
546− ::
547−```
548−
549−#### Examples
550−
551−```
552− > (trim 5 "lasok termun")
553− [p="lasok" q=" termun"]
554− > (trim 5 "zam")
555− [p="zam" q=""]
556−```
557−
558−
559−---
560−### `++trip`
561−
562−Cord to tape
563−
564−Produce a `++tape` from `++cord`.
565−
566−#### Accepts
567−
568−`a` is an atom.
569−
570−#### Produces
571−
572−A `++tape`.
573−
574−#### Source
575−
576−```hoon
577− ++ trip :: cord to tape
578− ~/ %trip
579− |= a/@ ^- tape
580− ?: =(0 (met 3 a))
581− ~
582− [^-(@ta (end 3 1 a)) $(a (rsh 3 1 a))]
583− ::
584−```
585−
586−#### Examples
587−
588−```
589− > (trip 'john doe')
590− "john doe"
591− > (trip 'abc 123 !@#')
592− "abc 123 !@#"
593− > (trip 'abc')
594− "abc"
595−```
596−
597−
598−---
599−### `++tuba`
600−
601−UTF8 to UTF32 tape
602−
603−Convert `++tape` to a `++list` of codepoints (`@c`).
604−
605−#### Accepts
606−
607−`a` is a `++tape`.
608−
609−#### Produces
610−
611−A `++list` of codepoints `@c`.
612−
613−#### Source
614−
615−```hoon
616− ++ tuba :: utf8 to utf32 tape
617− |= a/tape
618− ^- (list @c)
619− (rip 5 (turf (rap 3 a))) :: XX horrible
620− ::
621−```
622−
623−#### Examples
624−
625−```
626− > (tuba "я тут")
627− ~[~-~44f. ~-. ~-~442. ~-~443. ~-~442.]
628− > (tuba "chars")
629− ~[~-c ~-h ~-a ~-r ~-s]
630−```
631−
632−
633−---
634−### `++tufa`
635−
636−UTF32 to UTF8 tape
637−
638−Wrap a `++list` of utf32 codepoints into a utf8 `++tape`.
639−
640−#### Accepts
641−
642−`a` is a `++list` of `@c`.
643−
644−#### Produces
645−
646−A `++tape`.
647−
648−#### Source
649−
650−```hoon
651− ++ tufa :: utf32 to utf8 tape
652− |= a=(list @c)
653− ^- tape
654− ?~ a ""
655− (weld (rip 3 (tuft i.a)) $(a t.a))
656− ::
657−```
658−
659−#### Examples
660−
661−```hoon
662− > (tufa ~[~-~44f. ~-. ~-~442. ~-~443. ~-~442.])
663− "я тут"
664− > (tufa ((list @c) ~[%a %b 0xb1 %c]))
665− "ab±c"
666−```
667−
668−
669−---
670−### `++tuft`
671−
672−UTF32 to UTF8 text
673−
674−Convert utf32 glyph to
675−LSB utf8 `++cord`.
676−
677−#### Accepts
678−
679−`a` is a codepoint (`@c`).
680−
681−#### Produces
682−
683−A `++cord`.
684−
685−#### Source
686−
687−```hoon
688− ++ tuft :: utf32 to utf8 text
689− |= a/@c
690− ^- @t
691− %+ rap 3
692− |- ^- (list @)
693− ?: =(`@`0 a)
694− ~
695− =+ b=(end 5 1 a)
696− =+ c=$(a (rsh 5 1 a))
697− ?: (lte b 0x7f)
698− [b c]
699− ?: (lte b 0x7ff)
700− :* (mix 0b1100.0000 (cut 0 [6 5] b))
701− (mix 0b1000.0000 (end 0 6 b))
702− c
703− ==
704− ?: (lte b 0xffff)
705− :* (mix 0b1110.0000 (cut 0 [12 4] b))
706− (mix 0b1000.0000 (cut 0 [6 6] b))
707− (mix 0b1000.0000 (end 0 6 b))
708− c
709− ==
710− :* (mix 0b1111.0000 (cut 0 [18 3] b))
711− (mix 0b1000.0000 (cut 0 [12 6] b))
712− (mix 0b1000.0000 (cut 0 [6 6] b))
713− (mix 0b1000.0000 (end 0 6 b))
714− c
715− ==
716−```
717−
718−#### Examples
719−
720−```
721− > (tuft `@c`%a)
722− 'a'
723− > (tuft `@c`0xb6)
724− '¶'
725−```
726−
727−
728−---
729−### `++turf`
730−
731−UTF8 to UTF32 cord
732−
733−Convert utf8 (`++cord`) to utf32 codepoints.
734−
735−#### Accepts
736−
737−`a` is a `@t`.
738−
739−#### Produces
740−
741−A `@c`, UTF-32 codepoint.
742−
743−#### Source
744−
745−```hoon
746− ++ turf :: utf8 to utf32
747− |= a/@t
748− ^- @c
749− %+ rap 5
750− |- ^- (list @c)
751− =+ b=(teff a)
752− ?: =(0 b) ~
753− =+ ^= c
754− %+ can 0
755− %+ turn
756− ^- (list {p/@ q/@})
757− ?+ b !!
758− $1 [[0 7] ~]
759− $2 [[8 6] [0 5] ~]
760− $3 [[16 6] [8 6] [0 4] ~]
761− $4 [[24 6] [16 6] [8 6] [0 3] ~]
762− ==
763− |=({p/@ q/@} [q (cut 0 [p q] a)])
764− ?. =((tuft c) (end 3 b a)) ~|(%bad-utf8 !!)
765− [c $(a (rsh 3 b a))]
766− ::
767−```
768−
769−#### Examples
770−
771−```
772− > (turf 'my ßam')
773− ~-my.~df.am
774− > 'я тут'
775− 'я тут'
776− > (turf 'я тут')
777− ~-~44f..~442.~443.~442.
778− > `@ux`'я тут'
779− 0x82.d183.d182.d120.8fd1
780− > `@ux`(turf 'я тут')
781− 0x442.0000.0443.0000.0442.0000.0020.0000.044f
782−```
783−
784−
785−---
786−### `++wack`
787−
788−Coin format encode
789−
790−Escape `++span` `~` as `~~` and `_` as `~-`. Used for printing.
791−
792−#### Accepts
793−
794−`a` is a `++span` (`@ta`).
795−
796−#### Produces
797−
798−A `++span` (`@ta`).
799−
800−#### Source
801−
802−```hoon
803− ++ wack :: coin format
804− |= a/@ta
805− ^- @ta
806− =+ b=(rip 3 a)
807− %+ rap 3
808− |- ^- tape
809− ?~ b
810− ~
811− ?: =('~' i.b) ['~' '~' $(b t.b)]
812− ?: =('_' i.b) ['~' '-' $(b t.b)]
813− [i.b $(b t.b)]
814− ::
815−```
816−
817−#### Examples
818−
819−```
820− > (wack '~20_sam~')
821− ~.~~20~-sam~~
822−
823− > `@t`(wack '~20_sam~')
824− '~~20~-sam~~'
825−
826− > ~(rend co %many ~[`ud/5 `ta/'~20_sam'])
827− "._5_~~.~~20~-sam__"
828−
829− > ._5_~~.~~20~-sam__
830− [5 ~.~20_sam]
831−```
832−
833−---
834−### `++wick`
835−
836−Coin format decode
837−
838−Unescape `++span` `~~` as `~` and `~-` as `_`.
839−
840−#### Accepts
841−
842−`a` is a an atom.
843−
844−#### Produces
845−
846−A `++span` `@ta`.
847−
848−#### Source
849−
850−```hoon
851− ++ wick :: knot format
852− |= a/@
853− ^- (unit @ta)
854− =+ b=(rip 3 a)
855− =- ?^(b ~ (some (rap 3 (flop c))))
856− =| c/tape
857− |- ^- {b/tape c/tape}
858− ?~ b [~ c]
859− ?. =('~' i.b)
860− $(b t.b, c [i.b c])
861− ?~ t.b [b ~]
862− ?- i.t.b
863− $'~' $(b t.t.b, c ['~' c])
864− $'-' $(b t.t.b, c ['_' c])
865− @ [b ~]
866− ==
867− ::
868−```
869−
870−#### Examples
871−
872−```
873− > `@t`(wick '~-ams~~lop')
874− '_ams~lop'
875−
876− > `@t`(wick (wack '~20_sam~'))
877− '~20_sam~'
878−```
879−
880−
881−---
882−### `++woad`
883−
884−Unescape cord
885−
886−Unescape `++cord` codepoints.
887−
888−#### Accepts
889−
890−`a` is a `@ta`.
891−
892−#### Produces
893−
894−A `++cord`.
895−
896−#### Source
897−
898−```hoon
899− ++ woad :: cord format
900− |= a/@ta
901− ^- @t
902− %+ rap 3
903− |- ^- (list @)
904− ?: =(`@`0 a)
905− ~
906− =+ b=(end 3 1 a)
907− =+ c=(rsh 3 1 a)
908− ?: =('.' b)
909− [' ' $(a c)]
910− ?. =('~' b)
911− [b $(a c)]
912− => .(b (end 3 1 c), c (rsh 3 1 c))
913− ?+ b =- (weld (rip 3 (tuft p.d)) $(a q.d))
914− ^= d
915− =+ d=0
916− |- ^- {p/@ q/@}
917− ?: =('.' b)
918− [d c]
919− ?< =(0 c)
920− %= $
921− b (end 3 1 c)
922− c (rsh 3 1 c)
923− d %+ add (mul 16 d)
924− %+ sub b
925− ?: &((gte b '0') (lte b '9')) 48
926− ?>(&((gte b 'a') (lte b 'z')) 87)
927− ==
928− $'.' ['.' $(a c)]
929− $'~' ['~' $(a c)]
930− ==
931− ::
932−```
933−
934−#### Examples
935−
936−```
937− > (woad ~.~b6.20.as)
938− '¶20 as'
939−```
940−
941−
942−---
943−### `++wood`
944−
945−Escape cord
946−
947−Escape `++cord` codepoints.
948−
949−#### Accepts
950−
951−`a` is a `++span` (`@ta`).
952−
953−#### Produces
954−
955−A `++span` (`@ta`).
956−
957−#### Source
958−
959−```hoon
960− ++ wood :: cord format
961− |= a/@t
962− ^- @ta
963− %+ rap 3
964− |- ^- (list @)
965− ?: =(`@`0 a)
966− ~
967− =+ b=(teff a)
968− =+ c=(turf (end 3 b a))
969− =+ d=$(a (rsh 3 b a))
970− ?: ?| &((gte c 'a') (lte c 'z'))
971− &((gte c '0') (lte c '9'))
972− =(`@`'-' c)
973− ==
974− [c d]
975− ?+ c
976− :- '~'
977− =+ e=(met 2 c)
978− |- ^- tape
979− ?: =(0 e)
980− ['.' d]
981− =. e (dec e)
982− =+ f=(rsh 2 e c)
983− [(add ?:((lte f 9) 48 87) f) $(c (end 2 e c))]
984− ::
985−```
986−
987−#### Examples
988−
989−```
990− > (wood 'my ßam')
991− ~.my.~df.am
992−```
993−
994−---
reference/library/4c.mddeleted−364
@@ -1,364 +0,0 @@
1−+++
2−title = "4c: Tank Printer"
3−weight = 30
4−template = "doc.html"
5−aliases = ["/docs/reference/library/4c"]
6−+++
7−### `++re`
8−
9−Pretty-printing engine
10−
11−Pretty-printing engine that accepts a `++tank` sample and contains arms that perform computation on it.
12−
13−#### Accepts
14−
15−`tac` is a `++tank`.
16−
17−#### Produces
18−
19−```hoon
20− ++ re
21− |_ tac/tank
22−```
23−
24−#### Examples
25−
26−```
27− > ~(. re leaf+"ham")
28− <2.gdc {tac/{$leaf ""} <402.arm 110.jyx 1.ztu $151>}>
29−```
30−
31−---
32−### `++ram:re`
33−
34−Flatten to tape
35−
36−Flatten `++tank` out into a `++tape`.
37−
38−#### Accepts
39−
40−`tac` is a `++tank`, taken from sample of `++re` core.
41−
42−#### Produces
43−
44−A `++tape`.
45−
46−#### Source
47−
48−```hoon
49− ++ ram
50− ^- tape
51− ?- -.tac
52− $leaf p.tac
53− $palm ram(tac [%rose [p.p.tac (weld q.p.tac r.p.tac) s.p.tac] q.tac])
54− $rose
55− %+ weld
56− q.p.tac
57− |- ^- tape
58− ?~ q.tac
59− r.p.tac
60− =+ voz=$(q.tac t.q.tac)
61− (weld ram(tac i.q.tac) ?~(t.q.tac voz (weld p.p.tac voz)))
62− ==
63− ::
64−```
65−
66−#### Examples
67−
68−```
69− > ~(ram re leaf+"foo")
70− "foo"
71− > ~(ram re rose+["." "(" ")"]^~[leaf+"bar" leaf+"baz" leaf+"bam"])
72− "(bar.baz.bam)"
73−```
74−---
75−### `++win:re`
76−
77−Render at indent
78−
79−Render at indent level `tab` and width `edg`.
80−
81−#### Accepts
82−
83−`tac` is a `++tank`, taken from sample of `++re` core.
84−
85−`tab` and `edg` are atoms.
86−
87−#### Produces
88−
89−A `++wall` (`++list` of `++tapes`).
90−
91−#### Source
92−
93−```hoon
94− ++ win
95− |= {tab/@ edg/@}
96− =+ lug=`wall`~
97− |^ |- ^- wall
98− ?- -.tac
99− $leaf (rig p.tac)
100− $palm
101− ?: fit
102− (rig ram)
103− ?~ q.tac
104− (rig q.p.tac)
105− ?~ t.q.tac
106− (rig(tab (add 2 tab), lug $(tac i.q.tac)) q.p.tac)
107− => .(q.tac `(list tank)`q.tac)
108− =+ lyn=(mul 2 (lent q.tac))
109− =+ ^= qyr
110− |- ^- wall
111− ?~ q.tac
112− lug
113− %= ^$
114− tac i.q.tac
115− tab (add tab (sub lyn 2))
116− lug $(q.tac t.q.tac, lyn (sub lyn 2))
117− ==
118− (wig(lug qyr) q.p.tac)
119− ::
120−```
121−
122−#### Examples
123−
124−```
125− > (~(win re leaf+"samoltekon-lapdok") 0 20)
126− <<"samoltekon-lapdok">>
127−
128− > (~(win re leaf+"samoltekon-lapdok") 0 10)
129− <<"\/samolt\/" " ekon-l" " apdok" "\/ \/">>
130−
131− > (~(win re rose+["--" "[" "]"]^~[leaf+"1423" leaf+"2316"]) 0 20)
132− <<"[1423--2316]">>
133−
134− > (~(win re rose+["--" "[" "]"]^~[leaf+"1423" leaf+"2316"]) 0 10)
135− <<"[ 1423" " 2316" "]">>
136−```
137−
138−---
139−### `++din:re`
140−
141−XX document
142−
143−#### Accepts
144−
145−#### Produces
146−
147−#### Source
148−
149− ++ din (mod (add 2 tab) (mul 2 (div edg 3)))
150−
151−
152−---
153−
154−### `++fit:re`
155−
156−Fit on one line test
157−
158−Determine whether `tac` fits on one line. Internal to `++win`
159−
160−#### Accepts
161−
162−#### Produces
163−
164−#### Source
165−
166−++ fit (lte (lent ram) (sub edg tab))
167−
168−
169−#### Examples
170−
171−
172−
173−
174−---
175−
176−### `++rig:re`
177−
178−Wrap in `\/`
179−
180−Wrap `++tape` in `\/` if it doesn't fit at current indentation. Internal to
181−`++win`
182−
183−#### Accepts
184−
185−`tac` is a `++tank`, taken from sample of `++re` core.
186−
187−`hom` is a `++tape`.
188−
189−#### Produces
190−
191−A `++wall` (list of `++tape`s).
192−
193−#### Source
194−
195−```hoon
196− ++ rig
197− |= hom/tape
198− ^- wall
199− ?: & ::(lte (lent hom) (sub edg tab))
200− [(runt [tab ' '] hom) lug]
201− => .(tab (add tab 2), edg (sub edg 2))
202− =+ mut=(trim (sub edg tab) hom)
203− :- (runt [(sub tab 2) ' '] ['\\' '/' (weld p.mut `_hom`['\\' '/' ~])])
204− => .(hom q.mut)
205− |-
206− ?~ hom
207− :- %+ runt
208− [(sub tab 2) ' ']
209− ['\\' '/' (runt [(sub edg tab) ' '] ['\\' '/' ~])]
210− lug
211− => .(mut (trim (sub edg tab) hom))
212− [(runt [tab ' '] p.mut) $(hom q.mut)]
213− ::
214−```
215−
216−#### Examples
217−
218−---
219−### `++wig:re`
220−
221−`++win` render tape
222−
223−Render `++tape`. Internal to `++win`.
224−
225−#### Accepts
226−
227−`tac` is a `++tank`, taken from sample of `++re` core.
228−
229−`hom` is a `++tape`.
230−
231−#### Produces
232−
233−```hoon
234− ++ wig
235− |= hom/tape
236− ^- wall
237− ?~ lug
238− (rig hom)
239− =+ lin=(lent hom)
240− =+ wug=:(add 1 tab lin)
241− ?. =+ mir=i.lug
242− |- ?~ mir
243− |
244− ?|(=(0 wug) ?&(=(' ' i.mir) $(mir t.mir, wug (dec wug))))
245− (rig hom) :: ^ XX regular form?
246− [(runt [tab ' '] (weld hom `tape`[' ' (slag wug i.lug)])) t.lug]
247− --
248− --
249−```
250−
251−
252−
253−---
254−### `++show`
255−
256−```hoon
257− ++ show :: XX deprecated, use span
258− |= vem/*
259− |^ ^- tank
260− ?: ?=(@ vem)
261− [%leaf (mesc (trip vem))]
262− ?- vem
263− {s/$~ c/*}
264− [%leaf '\'' (weld (mesc (tape +.vem)) `tape`['\'' ~])]
265− ::
266− {s/$a c/@} [%leaf (mesc (trip c.vem))]
267− {s/$b c/*} (shop c.vem |=(a/@ ~(rub at a)))
268− {s/{$c p/@} c/*}
269− :+ %palm
270− [['.' ~] ['-' ~] ~ ~]
271− [[%leaf (mesc (trip p.s.vem))] $(vem c.vem) ~]
272− ::
273− {s/$d c/*} (shop c.vem |=(a/@ ~(rud at a)))
274− {s/$k c/*} (tank c.vem)
275− {s/$h c/*}
276− :+ %rose
277− [['/' ~] ['/' ~] ~]
278− =+ yol=((list @ta) c.vem)
279− (turn yol |=(a/@ta [%leaf (trip a)]))
280− ::
281− {s/$l c/*} (shol c.vem)
282− {s/$o c/*}
283− %= $
284− vem
285− :- [%m '%h:<[%d %d].[%d %d]>']
286− [-.c.vem +<-.c.vem +<+.c.vem +>-.c.vem +>+.c.vem ~]
287− ==
288− ::
289− {s/$p c/*} (shop c.vem |=(a/@ ~(rup at a)))
290− {s/$q c/*} (shop c.vem |=(a/@ ~(r at a)))
291− {s/$r c/*} $(vem [[%r ' ' '{' '}'] c.vem])
292− {s/$t c/*} (shop c.vem |=(a/@ ~(rt at a)))
293− {s/$v c/*} (shop c.vem |=(a/@ ~(ruv at a)))
294− {s/$x c/*} (shop c.vem |=(a/@ ~(rux at a)))
295− {s/{$m p/@} c/*} (shep p.s.vem c.vem)
296− {s/{$r p/@} c/*}
297− $(vem [[%r ' ' (cut 3 [0 1] p.s.vem) (cut 3 [1 1] p.s.vem)] c.vem])
298− ::
299− {s/{$r p/@ q/@ r/@} c/*}
300− :+ %rose
301− :* p=(mesc (trip p.s.vem))
302− q=(mesc (trip q.s.vem))
303− r=(mesc (trip r.s.vem))
304− ==
305− |- ^- (list tank)
306− ?@ c.vem
307− ~
308− [^$(vem -.c.vem) $(c.vem +.c.vem)]
309− ::
310− {s/$z c/*} $(vem [[%r %$ %$ %$] c.vem])
311− * !!
312− ==
313−```
314−
315−XX document
316−
317−### `++shep`
318−
319−```hoon
320− ++ shep
321− |= {fom/@ gar/*}
322− ^- tank
323− =+ l=(met 3 fom)
324− =+ i=0
325− :- %leaf
326− |- ^- tape
327− ?: (gte i l)
328− ~
329− =+ c=(cut 3 [i 1] fom)
330− ?. =(37 c)
331− (weld (mesc [c ~]) $(i +(i)))
332− =+ d=(cut 3 [+(i) 1] fom)
333− ?. .?(gar)
334− ['\\' '#' $(i (add 2 i))]
335− (weld ~(ram re (show d -.gar)) $(i (add 2 i), gar +.gar))
336− ::
337−```
338−
339−XX document
340−
341−### `++shop`
342−
343−```hoon
344− ++ shop
345− |= {aug/* vel/$-(a/@ tape)}
346− ^- tank
347− ?: ?=(@ aug)
348− [%leaf (vel aug)]
349− :+ %rose
350− [[' ' ~] ['[' ~] [']' ~]]
351− => .(aug `*`aug)
352− |- ^- (list tank)
353− ?: ?=(@ aug)
354− [^$ ~]
355− [^$(aug -.aug) $(aug +.aug)]
356− ::
357−```
358−
359−
360−XX document
361−
362−
363−
364−---
reference/library/4d.mddeleted−100
@@ -1,100 +0,0 @@
1−+++
2−title = "4d: Parsing (Tracing)"
3−weight = 31
4−template = "doc.html"
5−aliases = ["/docs/reference/library/4d"]
6−+++
7−### `++last`
8−
9−Further trace
10−
11−Compares two line-column pairs, `zyc` and `naz`, producing
12−whichever is further along.
13−
14−#### Accepts
15−
16−`naz` is a `hair`.
17−
18−`zyc` is a `hair`.
19−
20−#### Produces
21−
22−A `hair`.
23−
24−#### Source
25−
26−```hoon
27− ++ last |= [zyc=hair naz=hair]
28− ^- hair
29− ?: =(p.zyc p.naz)
30− ?:((gth q.zyc q.naz) zyc naz)
31− ?:((gth p.zyc p.naz) zyc naz)
32−```
33−
34−#### Examples
35−
36−```
37− > (last [1 1] [1 2])
38− [p=1 q=2]
39−
40− > (last [2 1] [1 2])
41− [p=2 q=1]
42−
43− > (last [0 0] [99 0])
44− [p=99 q=0]
45−
46− > (last [7 7] [7 7])
47− [p=7 q=7]
48−```
49−
50−---
51−### `++lust`
52−
53−Detect newline
54−
55−Advances `naz` by a row if the `weq` is a newline, or by a column if `weq` is
56−any other character.
57−
58−#### Accepts
59−
60−`weq` is a `char`.
61−
62−`naz` is a `hair`.
63−
64−#### Produces
65−
66−A hair.
67−
68−#### Source
69−
70−```hoon
71− ++ lust |= [weq=char naz=hair]
72− ^- hair
73− ?:(=(`@`10 weq) [+(p.naz) 1] [p.naz +(q.naz)])
74−```
75−
76−
77−#### Examples
78−
79−```
80− > (lust `a` [1 1])
81− [p=1 q=2]
82−
83− > (lust `@t`10 [1 1])
84− [p=2 q=1]
85−
86− > (lust '9' [10 10])
87− [p=10 q=11]
88−
89− > (roll "maze" [.(+<+ [1 1])]:lust)
90− [1 5]
91−
92− > %- roll :_ [.(+<+ [1 1])]:lust
93− """
94− Sam
95− lokes
96− """
97− [2 6]
98−```
99−
100−---
reference/library/4e.mddeleted−471
@@ -1,471 +0,0 @@
1−+++
2−title = "4e: Parsing (Combinators)"
3−weight = 32
4−template = "doc.html"
5−aliases = ["/docs/reference/library/4e"]
6−+++
7−### `++bend`
8−
9−Conditional composer
10−
11−Parsing composer: connects the `++edge` `vex` with the subsequent `++rule` `sab`
12−as an optional suffix, using gate `raq` to compose or reject its
13−result. If there is no suffix, or if the suffix fails to be composed
14−with the current result, the current result is produced. Used to map a
15−group of rules to a specified output.
16−
17−#### Accepts
18−
19−`raq` is a gate.
20−
21−`sab` is a rule.
22−
23−`vex` is an edge.
24−
25−#### Produces
26−
27−A `++rule`.
28−
29−#### Source
30−
31−```hoon
32− ++ bend :: conditional comp
33− ~/ %bend
34− |* raq/_|*({a/* b/*} [~ u=[a b]])
35− ~/ %fun
36− |* {vex/edge sab/rule}
37− ?~ q.vex
38− vex
39− =+ yit=(sab q.u.q.vex)
40− =+ yur=(last p.vex p.yit)
41− ?~ q.yit
42− [p=yur q=q.vex]
43− =+ vux=(raq p.u.q.vex p.u.q.yit)
44− ?~ vux
45− [p=yur q=q.vex]
46− [p=yur q=[~ u=[p=u.vux q=q.u.q.yit]]]
47− ::
48−```
49−
50−#### Examples
51−
52−```
53− > (;~((bend |=([a/char b/char] ?.(=(a b) ~ (some +(a))))) prn prn) [1 1] "qs")
54− [p=[p=1 q=3] q=[~ u=[p=~~q q=[p=[p=1 q=2] q="s"]]]]
55−
56− > (;~((bend |=([a/char b/char] ?.(=(a b) ~ (some +(a))))) prn prn) [1 1] "qqq")
57− [p=[p=1 q=3] q=[~ u=[p=~~r q=[p=[p=1 q=3] q="q"]]]]
58−
59− > (scan "aa" ;~((bend |=([a/char b/char] ?.(=(a b) ~ (some +(a))))) prn prn))
60− ~~b
61−
62− > (scan "ba" ;~((bend |=([a/char b/char] ?.(=(a b) ~ (some +(a))))) prn prn))
63− ! {1 3}
64− ! exit
65−
66− > `(unit @tas)`(scan "" ;~((bend) (easy ~) sym))
67− ~
68−
69− > `(unit @tas)`(scan "sep" ;~((bend) (easy ~) sym))
70− [~ %sep]
71−```
72−
73−
74−---
75−### `++comp`
76−
77−Arbitrary compose
78−
79−Parsing composer: connects the `++edge` `vex` with a following `++rule` `sab`,
80−combining the contents of `vex` with the result of `sab` using a binary
81−gate `raq`. Used to fold over the results of several `++rules`.
82−
83−#### Accepts
84−
85−`raq` is a gate that accepts a cell of two nouns, `a` and `b`, and
86−produces a cell of two nouns.
87−
88−`sab` is a rule.
89−
90−`vex` is an edge.
91−
92−#### Produces
93−
94−A `++rule`.
95−
96−#### Source
97−
98−```hoon
99− ++ comp
100− ~/ %comp
101− |* raq/_|*({a/* b/*} [a b]) :: arbitrary compose
102− ~/ %fun
103− |* {vex/edge sab/rule}
104− ~! +<
105− ?~ q.vex
106− vex
107− =+ yit=(sab q.u.q.vex)
108− =+ yur=(last p.vex p.yit)
109− ?~ q.yit
110− [p=yur q=q.yit]
111− [p=yur q=[~ u=[p=(raq p.u.q.vex p.u.q.yit) q=q.u.q.yit]]]
112− ::
113−```
114−
115−#### Examples
116−
117−```
118− > (scan "123" ;~((comp |=([a/@u b/@u] (add a b))) dit dit dit))
119− 6
120− > (scan "12" ;~((comp |=([a/@u b/@u] (add a b))) dit dit dit))
121− ! {1 3}
122− ! exit
123−```
124−
125−---
126−### `++fail`
127−
128−Never parse
129−
130−Produces an `++edge` at the same text position (`++hair`) with a failing
131−result (`q=~`).
132−
133−#### Accepts
134−
135−`tub` is a `++nail`.
136−
137−#### Produces
138−
139−An `++edge`.
140−
141−#### Source
142−
143−```hoon
144− ++ fail |=(tub/nail [p=p.tub q=~]) :: never parse
145−```
146−
147−#### Examples
148−
149−```
150− > (fail [[1 1] "abc"])
151− [p=[p=1 q=1] q=~]
152−
153− > (fail [[p=1.337 q=70] "Parse me, please?"])
154− [p=[p=1.337 q=70] q=~]
155−```
156−
157−
158−---
159−### `++glue`
160−
161−Skip delimiter
162−
163−Parsing composer: connects an `++edge` `vex` with a following `++rule` `sab` by
164−parsing the `++rule` `bus` (the delimiting symbol) and throwing out the
165−result.
166−
167−#### Accepts
168−
169−`bus` is a `++rule`.
170−
171−`sab` is a `++rule`.
172−
173−`vex` is an `++edge`.
174−
175−#### Produces
176−
177−
178−
179−#### Source
180−
181−```hoon
182− ++ glue :: add rule
183− ~/ %glue
184− |* bus/rule
185− ~/ %fun
186− |* {vex/edge sab/rule}
187− (plug vex ;~(pfix bus sab))
188− ::
189−```
190−
191−#### Examples
192−
193−```
194− > (scan "200|mal|bon" ;~((glue bar) dem sym sym))
195− [q=200 7.102.829 7.237.474]
196−
197− > `[@u @tas @tas]`(scan "200|mal|bon" ;~((glue bar) dem sym sym))
198− [200 %mal %bon]
199−
200− > (scan "200|;|bon" ;~((glue bar) dem sem sym))
201− [q=200 ~~~3b. 7.237.474]
202−
203− > (scan "200.;.bon" ;~((glue dot) dem sem sym))
204− [q=200 ~~~3b. 7.237.474]
205−```
206−
207−---
208−### `++less`
209−
210−Parse unless
211−
212−Parsing composer: if an `++edge` `vex` reflects a success, fail. Otherwise,
213−connect `vex` with the following `++rule`.
214−
215−#### Accepts
216−
217−`sab` is a `++rule`.
218−
219−`vex` is an `++edge`.
220−
221−#### Produces
222−
223−
224−
225−#### Source
226−
227−```hoon
228− ++ less :: no first and second
229− |* {vex/edge sab/rule}
230− ?~ q.vex
231− =+ roq=(sab)
232− [p=(last p.vex p.roq) q=q.roq]
233− (fail +<.sab)
234− ::
235−```
236−
237−#### Examples
238−
239−```
240− > (scan "sas-/lo" (star ;~(less lus bar prn)))
241− "sas-/lo"
242−
243− > (scan "sas-/l+o" (star ;~(less lus bar prn)))
244− ! {1 8}
245− ! exit
246−
247− > (scan "sas|-/lo" (star ;~(less lus bar prn)))
248− ! {1 5}
249− ! exit
250−```
251−
252−
253−---
254−### `++pfix`
255−
256−Discard first rule
257−
258−Parsing composer: connects an `++edge` `vex` with two subsequent `++rule`s,
259−ignoring the result of the first and producing the result of the second.
260−
261−#### Accepts
262−
263−`vex` is an edge.
264−
265−#### Produces
266−
267−
268−
269−#### Source
270−
271−```hoon
272− ++ pfix :: discard first rule
273− ~/ %pfix
274− (comp |*({a/* b/*} b))
275−```
276−
277−#### Examples
278−
279−```
280− > `@t`(scan "%him" ;~(pfix cen sym))
281− 'him'
282−
283− > (scan "+++10" ;~(pfix (star lus) dem))
284− q=10
285−```
286−
287−
288−---
289−### `++plug`
290−
291−Parse to tuple
292−
293−Parsing composer: connects an `++edge` `vex` with a following `++rule` `sab`, producing
294−a cell of both the results. See also: the monad applicator ;\~ for a
295−more detailed explanation.
296−
297−#### Accepts
298−
299−`sab` is a `++rule`.
300−
301−`vex` is an `++edge`.
302−
303−#### Produces
304−
305−
306−
307−#### Source
308−
309−```hoon
310− ++ plug :: first then second
311− ~/ %plug
312− |* {vex/edge sab/rule}
313− ?~ q.vex
314− vex
315− =+ yit=(sab q.u.q.vex)
316− =+ yur=(last p.vex p.yit)
317− ?~ q.yit
318− [p=yur q=q.yit]
319− [p=yur q=[~ u=[p=[p.u.q.vex p.u.q.yit] q=q.u.q.yit]]]
320− ::
321−```
322−
323−#### Examples
324−
325−```
326− > (scan "1..20" ;~(plug dem dot dot dem))
327− [q=1 ~~~. ~~~. q=20]
328−
329− > (scan "moke/~2014.1.1" ;~(plug sym fas nuck:so))
330− [1.701.539.693 ~~~2f. [% p=[p=~.da q=170.141.184.500.766.106.671.844.917.172.921.958.400]]]
331−
332− > ;;(,[@tas @t ~ %da @da] (scan "moke/~2014.1.1" ;~(plug sym fas nuck:so)))
333− [%moke '/' ~ %da ~2014.1.1]
334−```
335−
336−
337−---
338−### `++pose`
339−
340−Parse options
341−
342−Parsing composer: if `vex` reflects a failure, connect it with the
343−following rule `sab`. See also: the monad applicator ;\~
344−
345−#### Accepts
346−
347−`sab` is a `++rule`.
348−
349−`vex` is an `++edge`.
350−
351−#### Produces
352−
353−
354−
355−#### Source
356−
357−```hoon
358− ++ pose :: first or second
359− ~/ %pose
360− |* {vex/edge sab/rule}
361− ?~ q.vex
362− =+ roq=(sab)
363− [p=(last p.vex p.roq) q=q.roq]
364− vex
365− ::
366−```
367−
368−#### Examples
369−
370−```
371− > `@t`(scan "+" ;~(pose lus tar cen))
372− '+'
373−
374− > `@t`(scan "*" ;~(pose lus tar cen))
375− '*'
376−
377− > `@t`(scan "%" ;~(pose lus tar cen))
378− '%'
379−
380− > `@t`(scan "-" ;~(pose lus tar cen))
381− ! {1 1}
382− ! exit
383−```
384−
385−
386−---
387−### `++sfix`
388−
389−Discard second rule
390−
391−Parsing composer: connects `++edge`s `vex` with two subsequent `++rule`s returning the
392−result of the first and discarding the result of the second.
393−
394−#### Accepts
395−
396−`a` is the result of parsing the first `++rule`.
397−
398−`b` is the result of of parsing the second `++rule`.
399−
400−#### Produces
401−
402−
403−
404−#### Source
405−
406−```hoon
407− ++ sfix :: discard second rule
408− ~/ %sfix
409− (comp |*({a/* b/*} a))
410−```
411−
412−#### Examples
413−
414−```
415− > `@t`(scan "him%" ;~(sfix sym cen))
416− 'him'
417−
418− > (scan "10+++" ;~(sfix dem (star lus)))
419− q=10
420−```
421−
422−
423−---
424−### `++simu`
425−
426−First and second
427−
428−Parsing composer: if an `++edge` `vex` reflects a failure, fail. Otherwise,
429−connect `vex` with the following `++rule`.
430−
431−#### Accepts
432−
433−`sab` is a `++rule`.
434−
435−`vex` is an `++edge`.
436−
437−#### Produces
438−
439−
440−
441−#### Source
442−
443−```hoon
444− ++ simu :: first and second
445− |* {vex/edge sab/rule}
446− ?~ q.vex
447− vex
448− =+ roq=(sab)
449− roq
450− ::
451−```
452−
453−#### Examples
454−
455−```
456− > (scan "~zod" scat:vast)
457− [%dtzy p=%p q=0]
458−
459− > (scan "%zod" scat:vast)
460− [%dtzz p=%tas q=6.582.138]
461−
462− > (scan "%zod" ;~(simu cen scat:vast))
463− [%dtzz p=%tas q=6.582.138]
464−
465− > (scan "~zod" ;~(simu cen scat:vast))
466− ! {1 1}
467− ! exit
468−```
469−
470−
471−---
reference/library/4f.mddeleted−1195
@@ -1,1195 +0,0 @@
1−+++
2−title = "4f: Parsing (Rule-Builders)"
3−weight = 33
4−template = "doc.html"
5−aliases = ["/docs/reference/library/4f"]
6−+++
7−### `++bass`
8−
9−Parser modifier: LSB
10−ordered `++list` as atom of a `++base`.
11−
12−#### Accepts
13−
14−`wuc` is an atom.
15−
16−`tyd` is a `++rule`.
17−
18−#### Produces
19−
20−A `++rule`.
21−
22−#### Source
23−
24−```hoon
25− ++ bass
26− |* {wuc/@ tyd/rule}
27− %+ cook
28− |= waq/(list @)
29− %+ roll
30− waq
31− =|({p/@ q/@} |.((add p (mul wuc q))))
32− tyd
33− ::
34−```
35−
36−#### Examples
37−
38−```
39− > (scan "123" (bass 10 (star dit)))
40− q=123
41− > (scan "123" (bass 8 (star dit)))
42− q=83
43− > `@ub`(scan "123" (bass 8 (star dit)))
44− 0b101.0011
45−```
46−
47−
48−---
49−
50−### `++boss`
51−
52−Parser modifier: LSB
53−
54−Ordered `++list` as atom of a `++base`.
55−
56−#### Accepts
57−
58−`wuc` is an atom.
59−
60−`tyd` is a `++rule`.
61−
62−#### Produces
63−
64−A `++rule`.
65−
66−#### Source
67−
68−```hoon
69− ++ boss
70− |* {wuc/@ tyd/rule}
71− %+ cook
72− |= waq/(list @)
73− %+ reel
74− waq
75− =|({p/@ q/@} |.((add p (mul wuc q))))
76− tyd
77− ::
78−```
79−
80−#### Examples
81−
82−```
83− > (scan "123" (boss 10 (star dit)))
84− q=321
85−
86− > `@t`(scan "bam" (boss 256 (star alp)))
87− 'bam'
88−
89− > `@ux`(scan "bam" (boss 256 (star alp)))
90− 0x6d.6162
91−```
92−
93−---
94−### `++cold`
95−
96−Replace with constant
97−
98−Parser modifier. Accepts a `++rule` `sef` and produces a parser that
99−produces a constant `cus`, assuming `sef` is successful.
100−
101−#### Accepts
102−
103−`cus` is a constant noun.
104−
105−`sef` is a `++rule`.
106−
107−#### Produces
108−
109−An `++edge`.
110−
111−#### Source
112−
113−```hoon
114− ++ cold :: replace w+ constant
115− ~/ %cold
116− |* {cus/* sef/rule}
117− ~/ %fun
118− |= tub/nail
119− =+ vex=(sef tub)
120− ?~ q.vex
121− vex
122− [p=p.vex q=[~ u=[p=cus q=q.u.q.vex]]]
123−```
124−
125−#### Examples
126−
127−```
128− > ((cold %foo (just 'a')) [[1 1] "abc"])
129− [p=[p=1 q=2] q=[~ u=[p=%foo q=[p=[p=1 q=2] q="bc"]]]]
130−
131− > ((cold %foo (just 'a')) [[1 1] "bc"])
132− [p=[p=1 q=1] q=~]
133−```
134−
135−
136−---
137−### `++cook`
138−
139−Apply gate
140−
141−Parser modifier. Produces a parser that takes a (successful) result of a
142−`++rule` `sef` and slams it through `poq`.
143−
144−#### Accepts
145−
146−`poq` is a gate.
147−
148−`sef` is a `++rule`.
149−
150−#### Produces
151−
152−An `++rule`.
153−
154−#### Source
155−
156−```hoon
157− ++ cook :: apply gate
158− ~/ %cook
159− |* {poq/gate sef/rule}
160− ~/ %fun
161− |= tub/nail
162− =+ vex=(sef tub)
163− ?~ q.vex
164− vex
165− [p=p.vex q=[~ u=[p=(poq p.u.q.vex) q=q.u.q.vex]]]
166− ::
167−```
168−
169−#### Examples
170−
171−```
172− > ((cook ,@ud (just 'a')) [[1 1] "abc"])
173− [p=[p=1 q=2] q=[~ u=[p=97 q=[p=[p=1 q=2] q="bc"]]]]
174−
175− > ((cook ,@tas (just 'a')) [[1 1] "abc"])
176− [p=[p=1 q=2] q=[~ u=[p=%a q=[p=[p=1 q=2] q="bc"]]]]
177−
178− > ((cook |=(a=@ +(a)) (just 'a')) [[1 1] "abc"])
179− [p=[p=1 q=2] q=[~ u=[p=98 q=[p=[p=1 q=2] q="bc"]]]]
180−
181− > ((cook |=(a=@ `@t`+(a)) (just 'a')) [[1 1] "abc"])
182− [p=[p=1 q=2] q=[~ u=[p='b' q=[p=[p=1 q=2] q="bc"]]]]
183−```
184−
185−
186−---
187−### `++easy`
188−
189−Always parse
190−
191−Parser generator. Produces a parser that succeeds with given noun `huf`
192−without consuming any text.
193−
194−#### Accepts
195−
196−`huf` is a noun.
197−
198−#### Produces
199−
200−A `++rule`.
201−
202−#### Source
203−
204−```hoon
205− ++ easy :: always parse
206− ~/ %easy
207− |* huf=*
208− ~/ %fun
209− |= tub=nail
210− ^- (like ,_huf)
211− [p=p.tub q=[~ u=[p=huf q=tub]]]
212− ::
213−```
214−
215−#### Examples
216−
217−```
218− > ((easy %foo) [[1 1] "abc"])
219− [p=[p=1 q=1] q=[~ [p=%foo q=[p=[p=1 q=1] q="abc"]]]]
220−
221− > ((easy %foo) [[1 1] "bc"])
222− [p=[p=1 q=1] q=[~ [p=%foo q=[p=[p=1 q=1] q="bc"]]]]
223−
224− > ((easy 'a') [[1 1] "bc"])
225− [p=[p=1 q=1] q=[~ [p='a' q=[p=[p=1 q=1] q="bc"]]]]
226−```
227−
228−
229−---
230−### `++full`
231−
232−Parse to end
233−
234−Parser modifier. Accepts a `++rule` `sef`, and produces a parser that succeeds only
235−when the of `tub` is fully consumed using `sef`.
236−
237−#### Accepts
238−
239−`sef` is a `++rule`.
240−
241−#### Produces
242−
243−A `++rule`.
244−
245−#### Source
246−
247−```hoon
248− ++ full :: parse to end
249− |* sef=_rule
250− |= tub=nail
251− =+ vex=(sef tub)
252− ?~(q.vex vex ?:(=(~ q.q.u.q.vex) vex [p=p.vex q=~]))
253− ::
254−```
255−
256−#### Examples
257−
258−```
259− > ((full (just 'a')) [[1 1] "ab"])
260− [p=[p=1 q=2] q=~]
261−
262− > ((full (jest 'ab')) [[1 1] "ab"])
263− [p=[p=1 q=3] q=[~ u=[p='ab' q=[p=[p=1 q=3] q=""]]]]
264−
265− > ((full ;~(plug (just 'a') (just 'b'))) [[1 1] "ab"])
266− [p=[p=1 q=3] q=[~ u=[p=[~~a ~~b] q=[p=[p=1 q=3] q=""]]]]
267−```
268−
269−
270−---
271−### `++funk`
272−
273−Add to tape
274−
275−Parser modifier: prepend text to `++tape` before applying parser.
276−
277−#### Accepts
278−
279−`pre` is a `++tape`
280−
281−`sef` is a `++rule`
282−
283−#### Produces
284−
285−A `++rule`.
286−
287−#### Source
288−
289−```hoon
290− ++ funk :: add to tape first
291− |* {pre/tape sef/rule}
292− |= tub/nail
293− (sef p.tub (weld pre q.tub))
294−```
295−
296−#### Examples
297−
298−```
299− > ((funk "abc prefix-" (jest 'abc')) [[1 1] "to be parsed"])
300− [p=[p=1 q=4] q=[~ [p='abc' q=[p=[p=1 q=4] q=" prefix-to be parsed"]]]]
301−
302− > ((funk "parse" (just 'a')) [[1 4] " me"])
303− [p=[p=1 q=4] q=~]
304−```
305−
306−
307−---
308−### `++here`
309−
310−Place-based apply
311−
312−Parser modifier. Similar to `++cook` in that it produces a parser that takes a
313−(successful) result of `sef` and slams it through `hez`. `hez` accepts a
314−`++pint` `a` and a noun `b`, which is what the parser parsed.
315−
316−#### Accepts
317−
318−`hez` is a gate.
319−
320−`sef` is a `++rule`
321−
322−#### Produces
323−
324−A `++rule`.
325−
326−#### Source
327−
328−```hoon
329− ++ here :: place-based apply
330− ~/ %here
331− |* {hez/_|=({a/pint b/*} [a b]) sef/rule}
332− ~/ %fun
333− |= tub/nail
334− =+ vex=(sef tub)
335− ?~ q.vex
336− vex
337− [p=p.vex q=[~ u=[p=(hez [p.tub p.q.u.q.vex] p.u.q.vex) q=q.u.q.vex]]]
338− ::
339−```
340−
341−#### Examples
342−
343−```
344− > (scan "abc" (star alf))
345− "abc"
346−
347− > (scan "abc" (here |*(^ +<) (star alf)))
348− [[[p=1 q=1] p=1 q=4] "abc"]
349−
350− > (scan "abc" (star (here |*(^ +<) alf)))
351− ~[[[[p=1 q=1] p=1 q=2] ~~a] [[[p=1 q=2] p=1 q=3] ~~b] [[[p=1 q=3] p=1 q=4] ~~c]]
352−```
353−
354−
355−---
356−### `++ifix`
357−
358−Infix
359−
360−Parser modifier: surround with pair of `++rule`s, the output of which is
361−discarded.
362−
363−#### Accepts
364−
365−`fel` is a pair of `++rule`s.
366−
367−`hof` is a `++rule`.
368−
369−#### Produces
370−
371−A `++rule`.
372−
373−#### Source
374−
375−```hoon
376− ++ ifix
377− |* {fel/{rule rule} hof/rule}
378− ~! +<
379− ~! +<:-.fel
380− ~! +<:+.fel
381− ;~(pfix -.fel ;~(sfix hof +.fel))
382− ::
383−```
384−
385−#### Examples
386−
387−```
388− > (scan "-40-" (ifix [hep hep] dem))
389− q=40
390−
391− > (scan "4my4" (ifix [dit dit] (star alf)))
392− "my"
393−```
394−
395−
396−---
397−### `++jest`
398−
399−Match a cord
400−
401−Match and consume a cord.
402−
403−#### Accepts
404−
405−`daf` is a `@t`.
406−
407−#### Produces
408−
409−An `++edge`.
410−
411−#### Source
412−
413−```hoon
414− ++ jest :: match a cord
415− |= daf/@t
416− |= tub/nail
417− =+ fad=daf
418− |- ^- (like @t)
419− ?: =(`@`0 daf)
420− [p=p.tub q=[~ u=[p=fad q=tub]]]
421− ?: |(?=($~ q.tub) !=((end 3 1 daf) i.q.tub))
422− (fail tub)
423− $(p.tub (lust i.q.tub p.tub), q.tub t.q.tub, daf (rsh 3 1 daf))
424− ::
425−```
426−
427−#### Examples
428−
429−```
430− > ((jest 'abc') [[1 1] "abc"])
431− [p=[p=1 q=4] q=[~ [p='abc' q=[p=[p=1 q=4] q=""]]]]
432−
433− > (scan "abc" (jest 'abc'))
434− 'abc'
435−
436− > (scan "abc" (jest 'acb'))
437− ! {1 2}
438− ! 'syntax-error'
439− ! exit
440−
441− > ((jest 'john doe') [[1 1] "john smith"])
442− [p=[p=1 q=6] q=~]
443−
444− > ((jest 'john doe') [[1 1] "john doe"])
445− [p=[p=1 q=9] q=[~ [p='john doe' q=[p=[p=1 q=9] q=""]]]]
446−```
447−
448−
449−---
450−### `++just`
451−
452−Match a char
453−
454−Match and consume a single character.
455−
456−#### Accepts
457−
458−`daf` is a `++char`
459−
460−#### Produces
461−
462−A `++rule`.
463−
464−#### Source
465−
466−```hoon
467− ++ just :: XX redundant, jest
468− ~/ %just :: match a char
469− |= daf/char
470− ~/ %fun
471− |= tub/nail
472− ^- (like char)
473− ?~ q.tub
474− (fail tub)
475− ?. =(daf i.q.tub)
476− (fail tub)
477− (next tub)
478− ::
479−```
480−
481−#### Examples
482−
483−```
484− > ((just 'a') [[1 1] "abc"])
485− [p=[p=1 q=2] q=[~ [p=~~a q=[p=[p=1 q=2] q="bc"]]]]
486−
487− > (scan "abc" (just 'a'))
488− ! {1 2}
489− ! 'syntax-error'
490− ! exit
491−
492− > (scan "a" (just 'a'))
493−
494− ~~a
495− > (scan "%" (just '%'))
496− ~~~25.
497−```
498−
499−
500−---
501−### `++knee`
502−
503−Recursive parsers
504−
505−Used for recursive parsers, which would otherwise be infinite when
506−compiled.
507−
508−#### Accepts
509−
510−`gar` is a noun.
511−
512−`sef` is a gate that accepts a `++rule`
513−
514−#### Produces
515−
516−A `++rule`.
517−
518−#### Source
519−
520−```hoon
521− ++ knee :: callbacks
522− |* {gar/* sef/_|.(*rule)}
523− |= tub/nail
524− ^- (like _gar)
525− ((sef) tub)
526− ::
527−```
528−
529−#### Examples
530−
531−```
532− > |-(;~(plug prn ;~(pose $ (easy ~))))
533− ! rest-loop
534− ! exit
535−
536− > |-(;~(plug prn ;~(pose (knee *tape |.(^$)) (easy ~))))
537− < 1.obo
538− [ c=c=tub=[p=[p=@ud q=@ud] q=""]
539− b
540− < 1.bes
541− [ c=tub=[p=[p=@ud q=@ud] q=""]
542− b=<1.tnv [tub=[p=[p=@ud q=@ud] q=""] <1.ktu [daf=@tD <414.fvk 101.jzo 1.ypj %164>]>]>
543− a=<1.fvg [tub=[p=[p=@ud q=@ud] q=""] <1.khu [[les=@ mos=@] <414.fvk 101.jzo 1.ypj %164>]>]>
544− v=<414.fvk 101.jzo 1.ypj %164>
545− ]
546− >
547− a
548− ... 450 lines omitted ...
549− ]
550− >
551− > (scan "abcd" |-(;~(plug prn ;~(pose (knee *tape |.(^$)) (easy ~)))))
552− [~~a "bcd"]
553−```
554−
555−
556−---
557−### `++mask`
558−
559−Match char
560−
561−Parser generator. Matches the next character if it is in a list of
562−characters.
563−
564−#### Accepts
565−
566−`bud` is a list of `++char`
567−
568−#### Produces
569−
570−A `++rule`.
571−
572−#### Source
573−
574−```hoon
575− ++ mask :: match char in set
576− ~/ %mask
577− |= bud/(list char)
578− ~/ %fun
579− |= tub/nail
580− ^- (like char)
581− ?~ q.tub
582− (fail tub)
583− ?. (lien bud |=(a/char =(i.q.tub a)))
584− (fail tub)
585− (next tub)
586− ::
587−```
588−
589−#### Examples
590−
591−```
592− > (scan "a" (mask "cba"))
593− ~~a
594−
595− > ((mask "abc") [[1 1] "abc"])
596− [p=[p=1 q=2] q=[~ [p=~~a q=[p=[p=1 q=2] q="bc"]]]]
597−
598− > ((mask "abc") [[1 1] "bbc"])
599− [p=[p=1 q=2] q=[~ [p=~~b q=[p=[p=1 q=2] q="bc"]]]]
600−
601− > ((mask "abc") [[1 1] "dbc"])
602− [p=[p=1 q=1] q=~]
603−```
604−
605−---
606−### `++more`
607−
608−Parse list with delimiter
609−
610−Parser modifier: Parse a list of matches using a delimiter `++rule`.
611−
612−#### Accepts
613−
614−`bus` is a `++rule`.
615−
616−`fel` is a `++rule`.
617−
618−#### Produces
619−
620−A `++rule`.
621−
622−#### Source
623−
624−```hoon
625− ++ more
626− |* {bus/rule fel/rule}
627− ;~(pose (most bus fel) (easy ~))
628− ::
629−```
630−
631−#### Examples
632−
633−```
634− > (scan "" (more ace dem))
635− ~
636−
637− > (scan "40 20" (more ace dem))
638− [q=40 ~[q=20]]
639−
640− > (scan "40 20 60 1 5" (more ace dem))
641− [q=40 ~[q=20 q=60 q=1 q=5]]
642−```
643−
644−
645−---
646−### `++most`
647−
648−Parse list of at least one match
649−
650−Parser modifier: parse a `++list` of at least one match using a delimiter `++rule`.
651−
652−#### Accepts
653−
654−`bus` is a `++rule`.
655−
656−`fel` is a `++rule`.
657−
658−#### Produces
659−
660−A `++rule`.
661−
662−#### Source
663−
664−```hoon
665− ++ most
666− |* {bus/rule fel/rule}
667− ;~(plug fel (star ;~(pfix bus fel)))
668− ::
669−```
670−
671−#### Examples
672−
673−```
674− > (scan "40 20" (most ace dem))
675− [q=40 ~[q=20]]
676−
677− > (scan "40 20 60 1 5" (most ace dem))
678− [q=40 ~[q=20 q=60 q=1 q=5]]
679−
680− > (scan "" (most ace dem))
681− ! {1 1}
682− ! exit
683−```
684−
685−
686−---
687−### `++next`
688−
689−Consume char
690−
691−Consume any character, producing it as a result.
692−
693−#### Accepts
694−
695−`tub` is a `++nail`
696−
697−#### Produces
698−
699−An `++edge`.
700−
701−#### Source
702−
703−```hoon
704− ++ next :: consume a char
705− |= tub/nail
706− ^- (like char)
707− ?~ q.tub
708− (fail tub)
709− =+ zac=(lust i.q.tub p.tub)
710− [zac [~ i.q.tub [zac t.q.tub]]]
711− ::
712−```
713−
714−#### Examples
715−
716−```
717− > (next [[1 1] "ebc"])
718− [p=[p=1 q=2] q=[~ [p=~~e q=[p=[p=1 q=2] q="bc"]]]]
719−
720− > (next [[1 1] "john jumps jones"])
721− [p=[p=1 q=2] q=[~ [p=~~j q=[p=[p=1 q=2] q="ohn jumps jones"]]]]
722−```
723−
724−
725−---
726−
727−### `++plus`
728−
729−List of at least one match.
730−
731−Parser modifier: parse `++list` of at least one match.
732−
733−#### Accepts
734−
735−`fel` is a `++rule`.
736−
737−#### Produces
738−
739−A `++rule`.
740−
741−#### Source
742−
743−```hoon
744− ++ plus |*(fel/rule ;~(plug fel (star fel)))
745−```
746−
747−#### Examples
748−
749−```
750− > (scan ">>>>" (cook lent (plus gar)))
751− 4
752−
753− > (scan "- - " (plus ;~(pose ace hep)))
754− [~~- " - "]
755−
756− > `tape`(scan "- - " (plus ;~(pose ace hep)))
757− "- - "
758−
759− > `(pole ,@t)`(scan "- - " (plus ;~(pose ace hep)))
760− ['-' [' ' [' ' ['-' [' ' ~]]]]]
761−```
762−
763−
764−---
765−### `++sear`
766−
767−Conditional `++cook`
768−
769−Conditional `++cook`. Slams the result through a gate that produces
770−a unit; if that unit is empty, fail.
771−
772−#### Accepts
773−
774−`tub` is a `++nail`.
775−
776−#### Produces
777−
778−A `++rule`.
779−
780−#### Source
781−
782−```hoon
783− ++ sear :: conditional cook
784− |* {pyq/$-(* (unit)) sef/rule}
785− |= tub/nail
786− =+ vex=(sef tub)
787− ?~ q.vex
788− vex
789− =+ gey=(pyq p.u.q.vex)
790− ?~ gey
791− [p=p.vex q=~]
792− [p=p.vex q=[~ u=[p=u.gey q=q.u.q.vex]]]
793− ::
794−```
795−
796−#### Examples
797−
798−```
799− > ((sear |=(a/* ?@(a (some a) ~)) (just `a`)) [[1 1] "abc"])
800− [p=[p=1 q=2] q=[~ u=[p=97 q=[p=[p=1 q=2] q="bc"]]]]
801−
802− > ((sear |=(* ~) (just 'a')) [[1 1] "abc"])
803− [p=[p=1 q=2] q=~]
804−```
805−
806−
807−---
808−### `++shim`
809−
810−Char in range
811−
812−Match characters (`++char`) within a range.
813−
814−#### Accepts
815−
816−`les` is an atom.
817−
818−`mos` is an atom.
819−
820−#### Produces
821−
822−A `++rule`.
823−
824−#### Source
825−
826−```hoon
827− ++ shim :: match char in range
828− ~/ %shim
829− |= {les/@ mos/@}
830− ~/ %fun
831− |= tub/nail
832− ^- (like char)
833− ?~ q.tub
834− (fail tub)
835− ?. ?&((gte i.q.tub les) (lte i.q.tub mos))
836− (fail tub)
837− (next tub)
838− ::
839−```
840−
841−#### Examples
842−
843−```
844− > ((shim 'a' 'z') [[1 1] "abc"])
845− [p=[p=1 q=2] q=[~ [p=~~a q=[p=[p=1 q=2] q="bc"]]]]
846−
847− > ((shim 'a' 'Z') [[1 1] "abc"])
848− [p=[p=1 q=1] q=~]
849−
850− > ((shim 'a' 'Z') [[1 1] "Abc"])
851− [p=[p=1 q=2] q=[~ [p=~~~41. q=[p=[p=1 q=2] q="bc"]]]]
852−```
853−
854−
855−---
856−### `++slug`
857−
858−Use gate to parse delimited list
859−
860−Parser modifier: By composing with a gate, parse a delimited `++list` of
861−matches.
862−
863−#### Accepts
864−
865−`bus` is a `++rule`.
866−
867−`fel` is a `++rule`.
868−
869−#### Produces
870−
871−A `++rule`.
872−
873−#### Source
874−
875−```hoon
876− ++ slug
877− |* raq/_|*({a/* b/*} [a b])
878− |* {bus/rule fel/rule}
879− ;~((comp raq) fel (stir +<+.raq raq ;~(pfix bus fel)))
880− ::
881−```
882−
883−#### Examples
884−
885−```
886− > (scan "20+5+110" ((slug add) lus dem))
887− 135
888−
889− > `@t`(scan "a b c" ((slug |=(a/[@ @t] (cat 3 a))) ace alp))
890− 'abc'
891−```
892−
893−
894−---
895−### `++stag`
896−
897−Add label
898−
899−Add a label to an edge parsed by a rule.
900−
901−#### Accepts
902−
903−`gob` is a noun.
904−
905−`sef` is a rule.
906−
907−#### Produces
908−
909−A `++rule`.
910−
911−#### Source
912−
913−```hoon
914− ++ stag :: add a label
915− ~/ %stag
916− |* {gob/* sef/rule}
917− ~/ %fun
918− |= tub/nail
919− =+ vex=(sef tub)
920− ?~ q.vex
921− vex
922− [p=p.vex q=[~ u=[p=[gob p.u.q.vex] q=q.u.q.vex]]]
923− ::
924−```
925−
926−#### Examples
927−
928−```
929− > ((stag %foo (just 'a')) [[1 1] "abc"])
930− [p=[p=1 q=2] q=[~ u=[p=[%foo ~~a] q=[p=[p=1 q=2] q="bc"]]]]
931−
932− > ((stag "xyz" (jest 'abc')) [[1 1] "abc"])
933− [p=[p=1 q=4] q=[~ u=[p=["xyz" 'abc'] q=[p=[p=1 q=4] q=""]]]]
934−
935− > ((stag 10.000 (shim 0 100)) [[1 1] "abc"])
936− [p=[p=1 q=2] q=[~ u=[p=[10.000 ~~a] q=[p=[p=1 q=2] q="bc"]]]]
937−```
938−
939−
940−---
941−### `++star`
942−
943−List of matches
944−
945−Parser modifier: parse `++list` of matches.
946−
947−#### Accepts
948−
949−`fel` is a `++rule`.
950−
951−#### Produces
952−
953−```hoon
954− ++ star :: 0 or more times
955− |* fel/rule
956− (stir `(list _(wonk *fel))`~ |*({a/* b/*} [a b]) fel)
957−```
958−
959−#### Examples
960−
961−```
962− > (scan "aaaaa" (just 'a'))
963− ! {1 2}
964− ! 'syntax-error'
965− ! exit
966−
967− > (scan "aaaaa" (star (just 'a')))
968− "aaaaa"
969−
970− > (scan "abcdef" (star (just 'a')))
971− ! {1 2}
972− ! 'syntax-error'
973− ! exit
974−
975− > (scan "abcabc" (star (jest 'abc')))
976− <|abc abc|>
977−
978− > (scan "john smith" (star (shim 0 200)))
979− "john smith"
980−```
981−
982−
983−---
984−### `++stet`
985−
986−Add faces
987−
988−Add faces `[p q]` to range-parser pairs in a list.
989−
990−#### Accepts
991−
992−`leh` is a list of range-parsers.
993−
994−#### Produces
995−
996−
997−
998−#### Source
999−
1000−```hoon
1001− ++ stet
1002− |* leh/(list {?(@ {@ @}) rule})
1003− |-
1004− ?~ leh
1005− ~
1006− [i=[p=-.i.leh q=+.i.leh] t=$(leh t.leh)]
1007− ::
1008−```
1009−
1010−#### Examples
1011−
1012−```
1013− > (stet (limo [[5 (just 'a')] [1 (jest 'abc')] [[1 1] (shim 0 200)]
1014− [[1 10] (cold %foo (just 'a'))]~]))
1015− ~[
1016− [p=5 q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>]
1017− [p=1 q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>]
1018− [p=[1 1] q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>]
1019− [p=[1 10] q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>]
1020− ]
1021− > [[[1 1] (just 'a')] [[2 1] (shim 0 200)] ~]
1022− [ [[1 1] <1.tnv [tub=[p=[p=@ud q=@ud] q=""] <1.ktu [daf=@tD <414.fvk 101.jzo 1.ypj %164>]>]>]
1023− [[2 1] <1.fvg [tub=[p=[p=@ud q=@ud] q=""] <1.khu [[les=@ mos=@] <414.fvk 101.jzo 1.ypj %164>]>]>]
1024− ~
1025− ]
1026− > (stet (limo [[[1 1] (just 'a')] [[2 1] (shim 0 200)] ~]))
1027− ~[
1028− [p=[1 1] q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>]
1029− [p=[2 1] q=<1.lrk [tub=[p=[p=@ud q=@ud] q=""] <1.nqy [daf=@tD <394.imz 97.kdz 1.xlc %164>]>]>]
1030− ]
1031−```
1032−
1033−
1034−---
1035−### `++stew`
1036−
1037−Switch by first
1038−
1039−```hoon
1040− ++ stew :: switch by first char
1041− ~/ %stew
1042− |* leh/(list {p/?(@ {@ @}) q/rule}) :: char+range keys
1043− =+ ^= wor :: range complete lth
1044− |= {ort/?(@ {@ @}) wan/?(@ {@ @})}
1045− ?@ ort
1046− ?@(wan (lth ort wan) (lth ort -.wan))
1047− ?@(wan (lth +.ort wan) (lth +.ort -.wan))
1048− =+ ^= hel :: build parser map
1049− =+ hel=`(tree _?>(?=(^ leh) i.leh))`~
1050− |- ^+ hel
1051− ?~ leh
1052− ~
1053− =+ yal=$(leh t.leh)
1054− |- ^+ hel
1055− ?~ yal
1056− [i.leh ~ ~]
1057− ?: (wor p.i.leh p.n.yal)
1058− =+ nuc=$(yal l.yal)
1059− ?> ?=(^ nuc)
1060− ?: (vor p.n.yal p.n.nuc)
1061− [n.yal nuc r.yal]
1062− [n.nuc l.nuc [n.yal r.nuc r.yal]]
1063− =+ nuc=$(yal r.yal)
1064− ?> ?=(^ nuc)
1065− ?: (vor p.n.yal p.n.nuc)
1066− [n.yal l.yal nuc]
1067− [n.nuc [n.yal l.yal l.nuc] r.nuc]
1068− ~% %fun ..^$ ~
1069− |= tub/nail
1070− ?~ q.tub
1071− (fail tub)
1072− |-
1073− ?~ hel
1074− (fail tub)
1075− ?: ?@ p.n.hel
1076− =(p.n.hel i.q.tub)
1077− ?&((gte i.q.tub -.p.n.hel) (lte i.q.tub +.p.n.hel))
1078− :: (q.n.hel [(lust i.q.tub p.tub) t.q.tub])
1079− (q.n.hel tub)
1080− ?: (wor i.q.tub p.n.hel)
1081− $(hel l.hel)
1082− $(hel r.hel)
1083− ::
1084−```
1085−
1086−
1087−Parser generator. From an associative `++list` of characters or character
1088−ranges to `++rule`s, construct a `++map`, and parse `++tape`s only
1089−with `++rules` associated with a range that the `++tape`'s first character falls in.
1090−
1091−
1092−
1093−---
1094−### `++stir`
1095−
1096−Parse repeatedly
1097−
1098−Parse with `++rule` as many times as possible, and fold over results with a
1099−binary gate.
1100−
1101−#### Accepts
1102−
1103−`rud` is a noun.
1104−
1105−`raq` is a gate that takes two nouns and produces a cell.
1106−
1107−`fel` is a rule.
1108−
1109−#### Produces
1110−
1111−A rule.
1112−
1113−#### Source
1114−
1115−```hoon
1116− ++ stir
1117− ~/ %stir
1118− |* {rud/* raq/_=>(~ |*({a/* b/*} [a b])) fel/rule}
1119− ~/ %fun
1120− |= tub/nail
1121− ^- (like _rud)
1122− =+ vex=(fel tub)
1123− ?~ q.vex
1124− [p.vex [~ rud tub]]
1125− =+ wag=$(tub q.u.q.vex)
1126− ?> ?=(^ q.wag)
1127− [(last p.vex p.wag) [~ (raq p.u.q.vex p.u.q.wag) q.u.q.wag]]
1128−```
1129−
1130−#### Examples
1131−
1132−```
1133− > (scan "abc" (stir *@ add prn))
1134− 294
1135−
1136− > (roll "abc" add)
1137− b=294
1138−```
1139−
1140−
1141−---
1142−### `++stun`
1143−
1144−Parse several times
1145−
1146−Parse bounded number of times.
1147−
1148−#### Accepts
1149−
1150−`[les=@ mos=@]` is a cell of atoms indicating the bounds.
1151−
1152−`fel` is a `++rule`.
1153−
1154−#### Produces
1155−
1156−A `++rule`.
1157−
1158−#### Source
1159−
1160−```hoon
1161− ++ stun :: parse several times
1162− |* {lig/{@ @} fel/rule}
1163− |= tub/nail
1164− ^- (like (list _(wonk (fel))))
1165− ?: =(0 +.lig)
1166− [p.tub [~ ~ tub]]
1167− =+ vex=(fel tub)
1168− ?~ q.vex
1169− ?: =(0 -.lig)
1170− [p.vex [~ ~ tub]]
1171− vex
1172− =+ ^= wag %= $
1173− -.lig ?:(=(0 -.lig) 0 (dec -.lig))
1174− +.lig ?:(=(0 +.lig) 0 (dec +.lig))
1175− tub q.u.q.vex
1176− ==
1177− ?~ q.wag
1178− wag
1179− [p.wag [~ [p.u.q.vex p.u.q.wag] q.u.q.wag]]
1180−```
1181−
1182−#### Examples
1183−
1184−```
1185− > ((stun [5 10] prn) [1 1] "aquickbrownfoxran")
1186− [p=[p=1 q=11] q=[~ [p="aquickbrow" q=[p=[p=1 q=11] q="nfoxran"]]]]
1187−
1188− > ((stun [5 10] prn) [1 1] "aquickbro")
1189− [p=[p=1 q=10] q=[~ [p="aquickbro" q=[p=[p=1 q=10] q=""]]]]
1190−
1191− > ((stun [5 10] prn) [1 1] "aqui")
1192− [p=[p=1 q=5] q=~]
1193−```
1194−
1195−---
reference/library/4g.mddeleted−179
@@ -1,179 +0,0 @@
1−+++
2−title = "4g: Parsing (Outside Caller)"
3−weight = 34
4−template = "doc.html"
5−aliases = ["/docs/reference/library/4g"]
6−+++
7−### `++rash`
8−
9−Parse or crash
10−
11−Parse a cord with a given `++rule` and crash if the `++cord` isn't entirely
12−parsed.
13−
14−#### Accepts
15−
16−`naf` is an atom.
17−
18−`sab` is a `++rule`.
19−
20−#### Produces
21−
22−The value of the parse result, or crash.
23−
24−#### Source
25−
26−```hoon
27− ++ rash |*({naf/@ sab/rule} (scan (trip naf) sab)) ::
28−```
29−
30−#### Examples
31−
32−```
33− > (rash 'I was the world in which I walked, and what I saw' (star (shim 0 200)))
34− "I was the world in which I walked, and what I saw"
35−
36− > (rash 'abc' (just 'a'))
37− ! {1 2}
38− ! 'syntax-error'
39− ! exit
40−
41− > (rash 'abc' (jest 'abc'))
42− 'abc'
43−
44− > (rash 'abc' (jest 'ab'))
45− ! {1 3}
46− ! 'syntax-error'
47− ! exit
48−```
49−
50−
51−---
52−### `++rush`
53−
54−Parse or null
55−
56−Parse an atom with a given rule and produce null if the cord isn't
57−entirely parsed.
58−
59−#### Accepts
60−
61−`naf` is an atom.
62−
63−`sab` is a rule.
64−
65−#### Produces
66−
67−The value of the parse result, or null.
68−
69−#### Source
70−
71−```hoon
72− ++ rush |*({naf/@ sab/rule} (rust (trip naf) sab))
73−```
74−
75−#### Examples
76−
77−```
78− > (rush 'I was the world in which I walked, and what I saw' (star (shim 0 200)))
79− [~ "I was the world in which I walked, and what I saw"]
80−
81− > (rush 'abc' (just 'a'))
82− ~
83−
84− > (rush 'abc' (jest 'abc'))
85− [~ 'abc']
86−
87− > (rush 'abc' (jest 'ac'))
88− ~
89−
90− > (rush 'abc' (jest 'ab'))
91− ~
92−```
93−
94−
95−---
96−### `++rust`
97−
98−Parse tape or null
99−
100−Parse a `++tape` with a given `++rule` and produce null if the `++tape` isn't
101−entirely parsed.
102−
103−#### Accepts
104−
105−`los` is a `++tape`.
106−
107−`sab` is a `++rule`.
108−
109−#### Produces
110−
111−A `(unit ,@t)`
112−
113−#### Source
114−
115−```hoon
116− ++ rust |* {los/tape sab/rule}
117− =+ vex=((full sab) [[1 1] los])
118− ?~(q.vex ~ [~ u=p.u.q.vex])
119−```
120−
121−#### Examples
122−
123−```
124− > (rust "I was the world in which I walked, and what I saw" (star (shim 0 200)))
125− [~ "I was the world in which I walked, and what I saw"]
126−
127− > (rust "Or heard or felt came not but from myself;" (star (shim 0 200)))
128− [~ "Or heard or felt came not but from myself;"]
129−
130− > (rust "And there I found myself more truly and more strange." (jest 'And there I'))
131− ~
132−```
133−
134−
135−---
136−### `++scan`
137−
138−Parse tape or crash
139−
140−Parse a `++tape` with a given `++rule` and crash if the `++tape` isn't entirely
141−parsed.
142−
143−#### Accepts
144−
145−`los` is a tape.
146−
147−`sab` is a rule.
148−
149−#### Produces
150−
151−Either a `++tape` or a crash.
152−
153−#### Source
154−
155−```hoon
156− ++ scan |* {los/tape sab/rule}
157− =+ vex=((full sab) [[1 1] los])
158− ?~ q.vex
159− ~_ (show [%m '{%d %d}'] p.p.vex q.p.vex ~)
160− ~|('syntax-error' !!)
161− p.u.q.vex
162−```
163−
164−#### Examples
165−
166−```
167− > (scan "I was the world in which I walked, and what I saw" (star (shim 0 200)))
168− "I was the world in which I walked, and what I saw"
169−
170− > (scan "Or heard or felt came not but from myself;" (star (shim 0 200)))
171− "Or heard or felt came not but from myself;"
172−
173− > (scan "And there I found myself more truly and more strange." (jest 'And there I'))
174− ! {1 12}
175− ! 'syntax-error'
176− ! exit
177−```
178−
179−---
reference/library/4h.md+33−33
@@ -12,7 +12,7 @@ Parses ASCII character 32, space.
1212
1313#### Source
1414
15−```hoon
15+```reference
1616 ++ ace (just ' ')
1717```
1818
@@ -43,7 +43,7 @@ Parses ASCII character 124, the vertical bar.
4343
4444#### Source
4545
46−```hoon
46+```reference
4747 ++ bar (just '|')
4848```
4949
@@ -75,7 +75,7 @@ character, `\`.
7575
7676#### Source
7777
78−```hoon
78+```reference
7979 ++ bas (just '\\')
8080```
8181
@@ -108,7 +108,7 @@ Parses ASCII character 36, the dollar sign.
108108
109109#### Source
110110
111−```hoon
111+```reference
112112 ++ buc (just '$')
113113```
114114
@@ -138,7 +138,7 @@ Parses ASCII character 95, the underscore.
138138
139139#### Source
140140
141−```hoon
141+```reference
142142 ++ cab (just '_')
143143```
144144
@@ -168,7 +168,7 @@ Parses ASCII character 37, the percent sign.
168168
169169#### Source
170170
171−```hoon
171+```reference
172172 ++ cen (just '%')
173173```
174174
@@ -198,7 +198,7 @@ Parses ASCII character 58, the colon
198198
199199#### Source
200200
201−```hoon
201+```reference
202202 ++ col (just ':')
203203```
204204
@@ -227,7 +227,7 @@ Parses ASCII character 44, the comma.
227227
228228#### Source
229229
230−```hoon
230+```reference
231231 ++ com (just ',')
232232```
233233
@@ -257,7 +257,7 @@ Parses ASCII character 34, the double quote.
257257
258258#### Source
259259
260−```hoon
260+```reference
261261 ++ doq (just '"')
262262```
263263
@@ -292,7 +292,7 @@ Parses ASCII character 46, the period.
292292
293293#### Source
294294
295−```hoon
295+```reference
296296 ++ dot (just '.')
297297```
298298
@@ -322,7 +322,7 @@ Parses ASCII character 47, the forward slash.
322322
323323#### Source
324324
325−```hoon
325+```reference
326326 ++ fas (just '/')
327327```
328328
@@ -349,7 +349,7 @@ Parses ASCII character 60, the less-than sign.
349349
350350#### Source
351351
352−```hoon
352+```reference
353353 ++ gal (just '<')
354354```
355355
@@ -379,7 +379,7 @@ Parses ASCII character 62, the greater-than sign.
379379
380380#### Source
381381
382−```hoon
382+```reference
383383 ++ gar (just '>')
384384```
385385
@@ -409,7 +409,7 @@ Parses ASCII character 35, the number sign.
409409
410410#### Source
411411
412−```hoon
412+```reference
413413 ++ hax (just '#')
414414```
415415
@@ -436,7 +436,7 @@ Parses ASCII character 45, the hyphen.
436436
437437#### Source
438438
439−```hoon
439+```reference
440440 ++ hep (just '-')
441441```
442442
@@ -465,7 +465,7 @@ interpolation. To parse either of them, they must be escaped.
465465
466466#### Source
467467
468−```hoon
468+```reference
469469 ++ kel (just '{')
470470```
471471
@@ -494,7 +494,7 @@ interpolation. To parse either of them, they must be escaped.
494494
495495#### Source
496496
497−```hoon
497+```reference
498498 ++ ker (just '}')
499499```
500500
@@ -521,7 +521,7 @@ Parses ASCII character 94, the caret.
521521
522522#### Source
523523
524−```hoon
524+```reference
525525 ++ ket (just '^')
526526```
527527
@@ -547,7 +547,7 @@ Parses ASCII character 43, the plus sign.
547547
548548#### Source
549549
550−```hoon
550+```reference
551551 ++ lus (just '+')
552552```
553553
@@ -577,7 +577,7 @@ Parses ASCII character 38, the ampersand.
577577
578578#### Source
579579
580−```hoon
580+```reference
581581 ++ pam (just '&')
582582```
583583
@@ -607,7 +607,7 @@ Parses ASCII character 64, the "at" sign.
607607
608608#### Source
609609
610−```hoon
610+```reference
611611 ++ pat (just '@')
612612```
613613
@@ -637,7 +637,7 @@ Parses ASCII character 40, the left parenthesis.
637637
638638#### Source
639639
640−```hoon
640+```reference
641641 ++ pel (just '(')
642642```
643643
@@ -664,7 +664,7 @@ Parses ASCII character 41, the right parenthesis.
664664
665665#### Source
666666
667−```hoon
667+```reference
668668 ++ per (just ')')
669669```
670670
@@ -691,7 +691,7 @@ Parses ASCII character 91, the left square bracket.
691691
692692#### Source
693693
694−```hoon
694+```reference
695695 ++ sel (just '[')
696696```
697697
@@ -718,7 +718,7 @@ Parses ASCII character 59, the semicolon.
718718
719719#### Source
720720
721−```hoon
721+```reference
722722 ++ sem (just ';')
723723```
724724
@@ -745,7 +745,7 @@ Parses ASCII character 93, the right square bracket.
745745
746746#### Source
747747
748−```hoon
748+```reference
749749 ++ ser (just ']')
750750```
751751
@@ -772,7 +772,7 @@ Parses ASCII character 126, the tilde.
772772
773773#### Source
774774
775−```hoon
775+```reference
776776 ++ sig (just '~')
777777```
778778
@@ -800,7 +800,7 @@ Parses ASCII character 39, soq. Note the extra '' is to escape the first
800800
801801#### Source
802802
803−```hoon
803+```reference
804804 ++ soq (just '\'')
805805```
806806
@@ -827,7 +827,7 @@ Parses ASCII character 42, the asterisk.
827827
828828#### Source
829829
830−```hoon
830+```reference
831831 ++ tar (just '*')
832832```
833833
@@ -858,7 +858,7 @@ accent").
858858
859859#### Source
860860
861−```hoon
861+```reference
862862 ++ tec (just '`') :: backTiCk
863863```
864864
@@ -888,7 +888,7 @@ Parses ASCII character 61, the equals sign.
888888
889889#### Source
890890
891−```hoon
891+```reference
892892 ++ tis (just '=')
893893```
894894
@@ -914,7 +914,7 @@ Parses ASCII character 63, the question mark.
914914
915915#### Source
916916
917−```hoon
917+```reference
918918 ++ wut (just '?')
919919```
920920
@@ -941,7 +941,7 @@ Parses ASCII character 33, the exclamation point zap.
941941
942942#### Source
943943
944−```hoon
944+```reference
945945 ++ zap (just '!')
946946```
947947
reference/library/4i.mddeleted−1054
@@ -1,1054 +0,0 @@
1−+++
2−title = "4i: Parsing (Useful Idioms)"
3−weight = 36
4−template = "doc.html"
5−aliases = ["/docs/reference/library/4i"]
6−+++
7−### `++alf`
8−
9−Alphabetic characters
10−
11−Parse alphabetic characters, both upper and lowercase.
12−
13−#### Source
14−
15−```hoon
16− ++ alf ;~(pose low hig) :: alphabetic
17−```
18−
19−#### Examples
20−
21−```
22− > (scan "a" alf)
23− ~~a
24−
25− > (scan "A" alf)
26− ~~~41.
27−
28− > (scan "AaBbCc" (star alf))
29− "AaBbCc"
30−```
31−
32−
33−---
34−### `++aln`
35−
36−Alphanumeric characters
37−
38−Parse alphanumeric characters - both alphabetic characters and numbers.
39−
40−#### Source
41−
42−```hoon
43− ++ aln ;~(pose low hig nud) :: alphanumeric
44−```
45−
46−#### Examples
47−
48−```
49− > (scan "0" aln)
50− ~~0
51−
52− > (scan "alf42" (star aln))
53− "alf42"
54−
55− > (scan "0123456789abcdef" (star aln))
56− "0123456789abcdef"
57−```
58−
59−
60−---
61−### `++alp`
62−
63−Alphanumeric and `-`
64−
65−Parse alphanumeric strings and hep, "-".
66−
67−#### Source
68−
69−```hoon
70− ++ alp ;~(pose low hig nud hep) :: alphanumeric and -
71−```
72−
73−#### Examples
74−
75−```
76− > (scan "7" alp)
77− ~~7
78−
79− > (scan "s" alp)
80− ~~s
81−
82− > (scan "123abc-" (star alp))
83− "123abc-"
84−```
85−
86−
87−---
88−
89−### `++bet`
90−
91−Axis syntax `-`, `+`
92−
93−Parse the hep and lus axis syntax.
94−
95−#### Source
96−
97−```hoon
98− ++ bet ;~(pose (cold 2 hep) (cold 3 lus)) :: axis syntax - +
99−```
100−
101−#### Examples
102−
103−```
104− > (scan "-" bet)
105− 2
106−
107− > (scan "+" bet)
108− 3
109−```
110−
111−
112−---
113−### `++bin`
114−
115−Binary to atom
116−
117−Parse a tape of binary (0s and 1s) and produce its atomic representation.
118−
119−#### Source
120−
121−```hoon
122− ++ bin (bass 2 (most gon but)) :: binary to atom
123−```
124−
125−#### Examples
126−
127−```
128− > (scan "0000" bin)
129− 0
130−
131− > (scan "0001" bin)
132− 1
133−
134− > (scan "0010" bin)
135− 2
136−
137− > (scan "100000001111" bin)
138− 2.063
139−```
140−
141−
142−---
143−### `++but`
144−
145−Binary digit
146−
147−Parse a single binary digit.
148−
149−#### Source
150−
151−```hoon
152− ++ but (cook |=(a=@ (sub a '0')) (shim '0' '1')) :: binary digit
153−```
154−
155−#### Examples
156−
157−```
158− > (scan "0" but)
159− 0
160− > (scan "1" but)
161− 1
162− > (scan "01" but)
163− ! {1 2}
164− ! 'syntax-error'
165− ! exit
166− > (scan "01" (star but))
167− ~[0 1]
168−```
169−
170−
171−---
172−### `++cit`
173−
174−Octal digit
175−
176−Parse a single octal digit.
177−
178−#### Source
179−
180−```hoon
181− ++ cit (cook |=(a=@ (sub a '0')) (shim '0' '7')) :: octal digit
182−```
183−
184−#### Examples
185−
186−```
187− > (scan "1" cit)
188− 1
189− > (scan "7" cit)
190− 7
191− > (scan "8" cit)
192− ! {1 1}
193− ! 'syntax-error'
194− ! exit
195− > (scan "60" (star cit))
196− ~[6 0]
197−```
198−
199−
200−---
201−### `++dem`
202−
203−Decimal to atom
204−
205−Parse a decimal number to an atom.
206−
207−#### Source
208−
209−```hoon
210− ++ dem (bass 10 (most gon dit)) :: decimal to atom
211−```
212−
213−#### Examples
214−
215−```
216− > (scan "7" dem)
217− 7
218− > (scan "42" dem)
219− 42
220− > (scan "150000000" dem)
221− 150.000.000
222− > (scan "12456" dem)
223− 12.456
224−```
225−
226−
227−---
228−### `++dit`
229−
230−Decimal digit
231−
232−Parse a single decimal digit.
233−
234−#### Source
235−
236−```hoon
237− ++ dit (cook |=(a=@ (sub a '0')) (shim '0' '9')) :: decimal digit
238−```
239−
240−#### Examples
241−
242−```
243− > (scan "7" dit)
244− 7
245− > (scan "42" (star dit))
246− ~[4 2]
247− > (scan "26000" (star dit))
248− ~[2 6 0 0 0]
249−```
250−
251−
252−---
253−### `++dog`
254−
255−`.` optional gap
256−
257−Dot followed by an optional gap, used with numbers.
258−
259−#### Source
260−
261−```hoon
262− ++ dog ;~(plug dot gay) ::
263−```
264−
265−#### Examples
266−
267−```
268− > 1.234.703
269− 703
270− 1.234.703
271−
272− > (scan "a. " ;~(pfix alf dog))
273− [~~~. ~]
274−```
275−
276−
277−---
278−### `++doh`
279−
280−`@p` separator
281−
282−Phonetic base phrase separator
283−
284−#### Source
285−
286−```hoon
287− ++ doh ;~(plug ;~(plug hep hep) gay) ::
288−```
289−
290−#### Examples
291−
292−```
293− /> ~nopfel-botduc-nilnev-dolfyn--haspub-natlun-lodmur-holtyd
294− ~nopfel-botduc-nilnev-dolfyn--haspub-natlun-lodmur-holtyd
295− /> ~nopfel-botduc-nilnev-dolfyn--
296− haspub-natlun-lodmur-holtyd
297− ~nopfel-botduc-nilnev-dolfyn--haspub-natlun-lodmur-holtyd
298− > (scan "--" doh)
299− [[~~- ~~-] ~]
300− > (scan "-- " doh)
301− [[~~- ~~-] ~]
302−```
303−
304−
305−---
306−### `++dun`
307−
308−`--` to `~`
309−
310−Parse phep, `--`, to null, `~`.
311−
312−#### Source
313−
314−```hoon
315− ++ dun (cold ~ ;~(plug hep hep)) :: -- (phep) to ~
316−```
317−
318−#### Examples
319−
320−```
321− > (scan "--" dun)
322− ~
323− > (dun [[1 1] "--"])
324− [p=[p=1 q=3] q=[~ u=[p=~ q=[p=[p=1 q=3] q=""]]]]
325−```
326−
327−
328−---
329−
330−### `++duz`
331−
332−`==` to `~`
333−
334−Parse stet, `==`, to null `~`.
335−
336−#### Source
337−
338−```hoon
339− ++ duz (cold ~ ;~(plug tis tis)) :: == (stet) to ~
340−```
341−
342−#### Examples
343−
344−```
345− > (scan "==" duz)
346− ~
347− > (duz [[1 1] "== |=..."])
348− [p=[p=1 q=3] q=[~ u=[p=~ q=[p=[p=1 q=3] q=" |=..."]]]]
349−```
350−
351−
352−---
353−
354−### `++gah`
355−
356−Newline or ' '
357−
358−Whitespace component, either newline or space.
359−
360−#### Source
361−
362−```hoon
363− ++ gah (mask [`@`10 ' ' ~]) :: newline or ace
364−```
365−
366−#### Examples
367−
368−```
369− /> ^- * :: show spaces
370− """
371− -
372− -
373− -
374− """
375− [32 32 32 45 10 32 45 10 32 32 45 0]
376− /> ^- *
377− """
378−
379− """
380− [32 32 32 10 32 10 32 32 0]
381− /> ^- (list ,@)
382− %- scan :_ (star gah)
383− """
384−
385− """
386− ~[32 32 32 10 32 10 32 32]
387−```
388−
389−
390−---
391−### `++gap`
392−
393−Plural whitespace
394−
395−Separates tall runes
396−
397−#### Source
398−
399−```hoon
400− ++ gap (cold ~ ;~(plug gaq (star ;~(pose vul gah)))) :: plural whitespace
401−```
402−
403−
404−---
405−### `++gaq`
406−
407−End of line
408−
409−Two spaces, a newline, or comment.
410−
411−#### Source
412−
413−```hoon
414− ++ gaq ;~ pose :: end of line
415− (just `@`10)
416− ;~(plug gah ;~(pose gah vul))
417− vul
418− ==
419−```
420−
421−
422−
423−---
424−### `++gaw`
425−
426−Classic whitespace
427−
428−Terran whitespace.
429−
430−#### Source
431−
432−```hoon
433− ++ gaw (cold ~ (star ;~(pose vul gah))) :: classic white
434−```
435−
436−
437−---
438−### `++gay`
439−
440−Optional gap
441−
442−Optional gap.
443−
444−#### Source
445−
446−```hoon
447− ++ gay ;~(pose gap (easy ~)) ::
448−```
449−
450−---
451−### `++gon`
452−
453−Long numbers
454−
455−Parse long numbers - Numbers which wrap around the shell with the line
456−
457−#### Source
458−
459−```hoon
460− ++ gon ;~(pose ;~(plug bas gay fas) (easy ~)) :: long numbers \ /
461−```
462−
463−#### Examples
464−
465−```
466− > (scan "\\/" gon)
467− [~~~5c. ~ ~~~2f.]
468−
469− > (gon [[1 1] "\\/"])
470− [p=[p=1 q=3] q=[~ u=[p=[~~~5c. ~ ~~~2f.] q=[p=[p=1 q=3] q=""]]]]
471−```
472−
473−
474−---
475−### `++gul`
476−
477−Axis syntax `<` or `>`
478−
479−Parse the axis gal and gar axis syntax.
480−
481−#### Source
482−
483−```hoon
484− ++ gul ;~(pose (cold 2 gal) (cold 3 gar)) :: axis syntax < >
485−```
486−
487−#### Examples
488−
489−```
490− > (scan "<" gul)
491− 2
492−
493− > (scan ">" gul)
494− 3
495−```
496−
497−
498−---
499−### `++hex`
500−
501−Hex to atom
502−
503−Parse any hexadecimal number to an atom.
504−
505−#### Source
506−
507−```hoon
508− ++ hex (bass 16 (most gon hit)) :: hex to atom
509−```
510−
511−#### Examples
512−
513−```
514− > (scan "a" hex)
515− 10
516− > (scan "A" hex)
517− 10
518− > (scan "2A" hex)
519− 42
520− > (scan "1ee7" hex)
521− 7.911
522− > (scan "1EE7" hex)
523− 7.911
524− > (scan "1EE7F7" hex)
525− 2.025.463
526− > `@ux`(scan "1EE7F7" hex)
527− 0x1e.e7f7
528−```
529−
530−---
531−### `++hig`
532−
533−Uppercase
534−
535−Parse a single uppercase letter.
536−
537−#### Source
538−
539−```hoon
540− ++ hig (shim 'A' 'Z') :: uppercase
541−```
542−
543−#### Examples
544−
545−```
546− > (scan "G" hig)
547− ~~~47.
548−
549− > `cord`(scan "G" hig)
550− 'G'
551−
552− > (scan "ABCDEFGHIJKLMNOPQRSTUVWXYZ" (star hig))
553− "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
554−
555− > (hig [[1 1] "G"])
556− [p=[p=1 q=2] q=[~ [p=~~~47. q=[p=[p=1 q=2] q=""]]]]
557−```
558−
559−
560−---
561−### `++hit`
562−
563−Hex digits
564−
565−Parse a single hexadecimal digit.
566−
567−#### Source
568−
569−```hoon
570− ++ hit ;~ pose :: hex digits
571− dit
572− (cook |=(a=char (sub a 87)) (shim 'a' 'f'))
573− (cook |=(a=char (sub a 55)) (shim 'A' 'F'))
574− ==
575−```
576−
577−#### Examples
578−
579−```
580− > (scan "a" hit)
581− 10
582− > (scan "A" hit)
583− 10
584− > (hit [[1 1] "a"])
585− [p=[p=1 q=2] q=[~ [p=10 q=[p=[p=1 q=2] q=""]]]]
586− > (scan "2A" (star hit))
587− ~[2 10]
588−```
589−
590−---
591−### `++iny`
592−
593−Indentation block
594−
595−Apply `++rule` to indented block starting at current column number, omitting
596−the leading whitespace.
597−
598−#### Accepts
599−
600−`sef` is a `++rule`
601−
602−#### Produces
603−
604−A `++rule`.
605−
606−#### Source
607−
608−```hoon
609− ++ inde |* sef/rule :: indentation block
610− |= nail ^+ (sef)
611− =+ [har tap]=[p q]:+<
612− =+ lev=(fil 3 (dec q.har) ' ')
613− =+ eol=(just `@t`10)
614− =+ =- roq=((star ;~(pose prn ;~(sfix eol (jest lev)) -)) har tap)
615− ;~(simu ;~(plug eol eol) eol)
616− ?~ q.roq roq
617− =+ vex=(sef har(q 1) p.u.q.roq)
618− =+ fur=p.vex(q (add (dec q.har) q.p.vex))
619− ?~ q.vex vex(p fur)
620− =- vex(p fur, u.q -)
621− :+ &3.vex
622− &4.vex(q.p (add (dec q.har) q.p.&4.vex))
623− =+ res=|4.vex
624− |- ?~ res |4.roq
625− ?. =(10 -.res) [-.res $(res +.res)]
626− (welp [`@t`10 (trip lev)] $(res +.res))
627− ::
628−```
629−
630−#### Examples
631−
632−```
633− > (scan "abc" (iny (star ;~(pose prn (just `@`10)))))
634− "abc"
635− > (scan "abc" (star ;~(pose prn (just `@`10))))
636− "abc"
637− > (scan " abc\0ade" ;~(pfix ace ace (star ;~(pose prn (just `@`10)))))
638− "abc
639− de"
640− > (scan " abc\0ade" ;~(pfix ace ace (iny (star ;~(pose prn (just `@`10))))))
641− ! {1 6}
642− ! exit
643− > (scan " abc\0a de" ;~(pfix ace ace (iny (star ;~(pose prn (just `@`10))))))
644− "abc
645− de"
646−```
647−
648−
649−---
650−### `++low`
651−
652−Lowercase
653−
654−Parse a single lowercase letter.
655−
656−#### Source
657−
658−```hoon
659− ++ low (shim 'a' 'z') :: lowercase
660−```
661−
662−#### Examples
663−
664−```
665− > (scan "g" low)
666− ~~g
667− > `cord`(scan "g" low)
668− 'g'
669− > (scan "abcdefghijklmnopqrstuvwxyz" (star low))
670− "abcdefghijklmnopqrstuvwxyz"
671− > (low [[1 1] "g"])
672− [p=[p=1 q=2] q=[~ [p=~~g q=[p=[p=1 q=2] q=""]]]]
673−```
674−
675−
676−---
677−### `++mes`
678−
679−Hexbyte
680−
681−Parse a hexbyte.
682−
683−#### Source
684−
685−```hoon
686− ++ mes %+ cook :: hexbyte
687− |=({a/@ b/@} (add (mul 16 a) b))
688− ;~(plug hit hit)
689−```
690−
691−#### Examples
692−
693−```
694− > (scan "2A" mes)
695− 42
696− > (mes [[1 1] "2A"])
697− [p=[p=1 q=3] q=[~ u=[p=42 q=[p=[p=1 q=3] q=""]]]]
698− > (scan "42" mes)
699− 66
700−```
701−
702−
703−---
704−### `++nix`
705−
706−Letters and `-`
707−
708−Parse Letters and `-`.
709−
710−#### Source
711−
712−```hoon
713− ++ nix (boss 256 (star ;~(pose aln cab))) ::
714−```
715−
716−#### Examples
717−
718−```
719− > (scan "as_me" nix)
720− q=435.626.668.897
721−
722− > `@t`(scan "as_me" nix)
723− 'as_me'
724−```
725−
726−
727−---
728−
729−### `++nud`
730−
731−Numeric
732−
733−Parse a numeric character - A number.
734−
735−#### Source
736−
737−```hoon
738− ++ nud (shim '0' '9') :: numeric
739−```
740−
741−#### Examples
742−
743−```
744− > (scan "0" nud)
745− ~~0
746− > (scan "7" nud)
747− ~~7
748− > (nud [[1 1] "1"])
749− [p=[p=1 q=2] q=[~ [p=~~1 q=[p=[p=1 q=2] q=""]]]]
750− > (scan "0123456789" (star nud))
751− "0123456789"
752−```
753−
754−---
755−### `++prn`
756−
757−Printable character
758−
759−Parse any printable character.
760−
761−#### Source
762−
763−```hoon
764− ++ prn ;~(less (just `@`127) (shim 32 256))
765−```
766−
767−#### Examples
768−
769−```
770− > (scan "h" prn)
771− ~~h
772− > (scan "!" prn)
773− ~~~21.
774− > (scan "\01" prn)
775− ! {1 1}
776− ! exit
777−```
778−
779−
780−---
781−### `++qit`
782−
783−Chars in cord
784−
785−Parse an individual character to its cord atom representation.
786−
787−#### Source
788−
789−```hoon
790− ++ qit ;~ pose :: chars in a cord
791− ;~(less bas soq prn)
792− ;~(pfix bas ;~(pose bas soq mes)) :: escape chars
793− ==
794−```
795−
796−#### Examples
797−
798−```
799− > (scan "%" qit)
800− 37
801− > `@t`(scan "%" qit)
802− '%'
803− > (scan "0" qit)
804− 48
805− > (scan "E" qit)
806− 69
807− > (scan "a" qit)
808− 97
809− > (scan "\\0a" qit)
810− 10
811− > `@ux`(scan "\\0a" qit)
812− 0xa
813− > (scan "cord" (star qit))
814− ~[99 111 114 100]
815−```
816−
817−
818−---
819−### `++qit`
820−
821−Chars in cord
822−
823−Parse an individual character to its cord atom representation.
824−
825−#### Source
826−
827−```hoon
828− ++ qit ;~ pose :: chars in a cord
829− ;~(less bas soq prn)
830− ;~(pfix bas ;~(pose bas soq mes)) :: escape chars
831− ==
832−```
833−
834−#### Examples
835−
836−```
837− > (scan "%" qit)
838− 37
839− > `@t`(scan "%" qit)
840− '%'
841− > (scan "0" qit)
842− 48
843− > (scan "E" qit)
844− 69
845− > (scan "a" qit)
846− 97
847− > (scan "\\0a" qit)
848− 10
849− > `@ux`(scan "\\0a" qit)
850− 0xa
851− > (scan "cord" (star qit))
852− ~[99 111 114 100]
853−```
854−
855−
856−
857−---
858−### `++qut`
859−
860−Cord
861−
862−Parse single-soq cord with `\{gap}/` anywhere in the middle, or triple-single
863−quote (aka triple-soq) cord, between which must be in an indented block.
864−
865−#### Source
866−
867−```hoon
868− ++ qut ;~ pose :: cord
869− ;~ less soqs
870− (ifix [soq soq] (boss 256 (more gon qit)))
871− ==
872− %- inde %+ ifix
873− :- ;~ plug soqs
874− ;~(pose ;~(plug (plus ace) vul) (just '\0a'))
875− ==
876− ;~(plug (just '\0a') soqs)
877− (boss 256 (star qat))
878− ==
879− ::
880−```
881−
882−#### Examples
883−
884−```
885− > (scan "'cord'" qut)
886− q=1.685.221.219
887− > 'cord'
888− 'cord'
889− > `@ud`'cord'
890− 1.685.221.219
891− > '''
892− Heredoc isn't prohibited from containing quotes
893− '''
894− 'Heredoc isn't prohibited from containing quotes'
895−```
896−
897−
898−---
899−### `++soz`
900−
901−Delimiting `'''`
902−
903−Parse a triple-single quote, used for multiline strings.
904−
905−#### Source
906−
907−```hoon
908− ++ soz ;~(plug soq soq soq) :: delimiting '''
909−```
910−
911−#### Examples
912−
913−```
914− > (scan "'''" soz)
915− [~~~27. ~~~27. ~~~27.]
916− > (rash '"""' soz)
917− ! {1 1}
918− ! exit
919−```
920−
921−
922−---
923−### `++sym`
924−
925−Term
926−
927−A term: a letter(lowercase), followed by letters, numbers, or `-`.
928−
929−#### Source
930−
931−```hoon
932− ++ sym
933− %+ cook
934− |=(a=tape (rap 3 ^-((list ,@) a)))
935− ;~(plug low (star ;~(pose nud low hep)))
936− ::
937−```
938−
939−#### Examples
940−
941−```
942− > (scan "sam-2" sym)
943− 215.510.507.891
944− > `@t`(scan "sam-2" sym)
945− 'sam-2'
946− > (scan "sym" sym)
947− 7.174.515
948−```
949−
950−
951−---
952−### `++ven`
953−
954−`+>-` axis syntax
955−
956−Axis syntax parser
957−
958−#### Source
959−
960−```hoon
961− ++ ven ;~ (comp |=({a/@ b/@} (peg a b))) :: +>- axis syntax
962− bet
963− =+ hom=`?`|
964− |= tub/nail
965− ^- (like axis)
966− =+ vex=?:(hom (bet tub) (gul tub))
967− ?~ q.vex
968− [p.tub [~ 1 tub]]
969− =+ wag=$(p.tub p.vex, hom !hom, tub q.u.q.vex)
970− ?> ?=(^ q.wag)
971− [p.wag [~ (peg p.u.q.vex p.u.q.wag) q.u.q.wag]]
972− ==
973−```
974−
975−#### Examples
976−
977−```
978− ~zod/arvo=/hoon/hoon> (scan "->+" ven)
979− 11
980−
981− ~zod/arvo=/hoon/hoon> `@ub`(scan "->+" ven)
982− 0b1011
983−
984− ~zod/arvo=/hoon/hoon> (peg (scan "->" ven) (scan "+" ven))
985− 11
986−
987− ~zod/arvo=/hoon/hoon> ->+:[[1 2 [3 4]] 5]
988− [3 4]
989−```
990−
991−
992−---
993−### `++vit`
994−
995−Base64 digit
996−
997−Parse a standard base64 digit.
998−
999−#### Source
1000−
1001−```hoon
1002− ++ vit :: base64 digit
1003− ;~ pose
1004− (cook |=(a/@ (sub a 65)) (shim 'A' 'Z'))
1005− (cook |=(a/@ (sub a 71)) (shim 'a' 'z'))
1006− (cook |=(a/@ (add a 4)) (shim '0' '9'))
1007− (cold 62 (just '-'))
1008− (cold 63 (just '+'))
1009− ==
1010−```
1011−
1012−#### Examples
1013−
1014−```
1015− ~zod/arvo=/hoon/hoon> (scan "C" vit)
1016− 2
1017− ~zod/arvo=/hoon/hoon> (scan "c" vit)
1018− 28
1019− ~zod/arvo=/hoon/hoon> (scan "2" vit)
1020− 54
1021− ~zod/arvo=/hoon/hoon> (scan "-" vit)
1022− 62
1023−```
1024−
1025−---
1026−### `++vul`
1027−
1028−Comments to null
1029−
1030−#### Source
1031−
1032−```hoon
1033− ++ vul %+ cold ~ :: comments
1034− ;~ plug col col
1035− (star prn)
1036− (just `@`10)
1037− ==
1038−```
1039−
1040−Parse comments and produce a null. Note that a comment must be ended
1041−with a newline character.
1042−
1043−#### Examples
1044−
1045−```
1046− > (scan "::this is a comment \0a" vul)
1047− ~
1048− > (scan "::this is a comment " vul)
1049− ! {1 21}
1050− ! exit
1051−```
1052−
1053−
1054−---
reference/library/4j.mddeleted−1656

This diff is too big to show here.

reference/library/4k.mddeleted−276

This diff is too big to show here.

reference/library/4l.mddeleted−608

This diff is too big to show here.

reference/library/4m.mddeleted−434

This diff is too big to show here.

reference/library/4n.mddeleted−447

This diff is too big to show here.

reference/library/4o.mddeleted−782

This diff is too big to show here.

reference/library/5a.mddeleted−7

This diff is too big to show here.

reference/library/5b.mddeleted−7

This diff is too big to show here.

reference/library/5c.mddeleted−7

This diff is too big to show here.

reference/library/5d.mddeleted−7

This diff is too big to show here.

reference/library/5e.mddeleted−7

This diff is too big to show here.

reference/library/5f.mddeleted−176

This diff is too big to show here.

reference/library/5g.mddeleted−7

This diff is too big to show here.

reference/library/_index.mddeleted−1733

This diff is too big to show here.

reference/library/table-of-contents.mddeleted−1730

This diff is too big to show here.

reference/library/zuse.mddeleted−10

This diff is too big to show here.

tutorials/arvo/glossary.mddeleted−850

This diff is too big to show here.

tutorials/nock/implementations.md+1−1

This diff is too big to show here.