on master help sign in
resolve merge conflits from restructure-3
eab26ffDavid Kerschner
_index.md+4−8
@@ -20,16 +20,12 @@ The Operator's Manual will show you how to perform everyday functions on your Ur
20
20
21This guide will teach you how set up an Urbit development environment.
21This guide will teach you how set up an Urbit development environment.
22
22
23−## Technical Documentation
23+## Documentation
24
24
25The documentation proper is contained on the sidebar of this page. It's meant for those interested in development on Urbit, and it's sorted by section:
25The documentation proper is contained on the sidebar of this page. It's meant for those interested in development on Urbit, and it's sorted by section:
26
26
27−- [Arvo](../arvo) is the Urbit operating system. If you're interested in finding out about the architecture of the system, check out this section.
27+- [Concepts](concepts) gives an in-depth, high-level explanations of Urbit concepts.
28
28
29−- [Azimuth](../azimuth) is the Urbit identity layer. To use Urbit, you need an identity that is secured by Azimuth.
29+- [Tutorials](tutorials) contains tutorials all the details about the system, enough where you can develop on Urbit. There are sections on Arvo, the Urbit OS; Hoon, Urbit's functional programming language; Nock, the the low-level language Hoon compiles to; and Vere, the Nock interpreter that acts as the layer between Urbit and whatever system (MacOS, Linux, BSD) is running it.
30
30
31−- [Hoon](../hoon) is the functional programming language used to build Urbit. This section contains tutorials that will help you build proficiency in the language.
31+- [Reference](reference) contains technical reference documentation for Hoon and other components of the system. Keep reading if you need to look up a Hoon expression or a standard-library function.
32−
33−- [Nock](../nock) is the low-level language Hoon compiles to. If you want to understand that absolute fundamentals of Urbit, this section will be of help.
34−
35−- [Vere](../vere) is the Nock interpreter that acts as the layer between Urbit and whatever system (MacOS, Linux, BSD) is running it.
arvo/hall.mddeleted−1335
@@ -1,1335 +0,0 @@
1−+++
2−title = "Hall"
3−weight = 7
4−template = "doc.html"
5−aliases = ["docs/learn/arvo/hall/"]
6−+++
7−> Last major revision of this tutorial: 2017. Some of the information and Hoon syntax here may
8− be outdated.
9−
10−
11−Hall is the Urbit messaging and notifications protocol. This document details Hall's architecture, its interfaces, and the new Gall model it's built to target.
12−
13−## Table of contents
14−
15−- [Hall Architecture](#hall-architecture)
16−
17−- [The Hall Interface](#the-hall-interface)
18−
19−- [The New Gall Model](#the-new-gall-model)
20−
21−# Hall Architecture
22−
23−This document is complemented by Hall's source code, but doesn't require it. Definitions of data structures, code snippets and diagrams will be provided where useful.
24−
25−Hall's implementation is structured according to the new Gall model. Familiarity with its concepts is assumed. See [the new Gall model](#the-new-gall-model).
26−
27−## Talk
28−
29−Talk was Urbit's first big user-facing application. It continues to enjoy a prominent role in the Urbit landscape, but now does so as two separate applications.
30−
31−The messaging parts of Talk have been separated from its user-interface parts. What we ended up with is a shiny new generic messaging bus, and the chat interface we all know and love. The messaging bus, which should now prove useful to many different applications, will be named `Hall`. Applications that use it are referred to as **clients**. One such application, as you might have guessed, is `:talk`.
32−
33−
34−## Structures & functionality
35−
36−### Circles
37−
38−```hoon
39−++ circle {hos/ship nom/term} :: native target
40−```
41−
42−A `circle` is essentially a named collection of messages created by and hosted on a ship's Hall, usually represented as `~ship-name/circle-name`. Most of Hall revolves around doing things with circles.
43−
44−### Messages
45−
46−When we subscribe to a circle, the primary thing we're interested in is its messages. Message data itself isn't that complicated, but a fair amount of metadata comes into play when actually sending a message. Let's work our way up, starting at the contents.
47−
48−```hoon
49−++ speech :> content body
50− $% {$lin pat/? msg/cord} :< no/@ text line
51− {$url url/purf:eyre} :< parsed url
52− {$exp exp/cord res/(list tank)} :< hoon line
53− {$ire top/serial sep/speech} :< in reply to
54− {$fat tac/attache sep/speech} :< attachment
55− {$app app/term sep/speech} :< app message
56− {$inv inv/? cir/circle} :< inv/ban for circle
57− == ::
58−```
59−
60−At the heart of every message lies a `speech` that describes the message body. There's a large number of different speech types, from simple text messages to parsed URLs, Hoon expressions and more.
61−
62−```hoon
63−++ audience (set circle) :< destinations
64−++ serial @uvH :< unique identifier
65−++ thought :> inner message
66− $: uid/serial :< unique identifier
67− aud/audience :< destinations
68− wen/@da :< timestamp
69− sep/speech :< content
70− == ::
71−```
72−
73−A `speech` is always accompanied by various bits of metadata. We include a unique identifier, a message timestamp and an `audience`, the set of all intended recipients of the message.
74−
75−```hoon
76−++ telegram {aut/ship thought} :< whose message
77−++ envelope {num/@ud gam/telegram} :< outward message
78−```
79−
80−Finally, before sending the message over the wire, we add on the message's original author. In most cases, we also include a sequence number, the index of the message in the originating circle's list of messages. This can be a useful point of reference for clients.
81−
82−### Participant metadata
83−
84−Messages aren't the only thing a subscription gets us. We're also kept up to date with relevant metadata.
85−
86−```hoon
87−++ crowd {loc/group rem/(map partner group)} :< our & srcs presences
88−++ group (map ship status) :< presence map
89−++ status {pec/presence man/human} :< participant
90−++ presence :> status type
91− $? $gone :< absent
92− $idle :< idle
93− $hear :< present
94− $talk :< typing
95− == ::
96−++ human :> human identifier
97− $: han/(unit cord) :< handle
98− tru/(unit truename) :< true name
99− == ::
100−++ truename {fir/cord mid/(unit cord) las/cord} :< real-life name
101−```
102−
103−`status` is user-set metadata that describes, well, the status of users in a circle. This encompasses their `presence`, which shows their activity, and their `human` identity, which includes their display handle.
104−
105−For reasons we'll discover shortly, circles keep track of both their own `group` and those of the circles they're subscribed to. `crowd` encapsulates this.
106−
107−### Configurations
108−
109−```hoon
110−++ lobby {loc/config rem/(map circle config)} :< our & srcs configs
111−++ config :> circle config
112− $: src/(set circle) :< active sources
113− cap/cord :< description
114− fit/filter :< message rules
115− con/control :< restrictions
116− == ::
117−++ filter :> content filters
118− $: cas/? :< dis/allow capitals
119− utf/? :< dis/allow non-ascii
120− == ::
121−++ control {sec/security ses/(set ship)} :< access control
122−```
123−
124−Another part of metadata we get from circle subscriptions is configurations. Again, circles want to remember their own configuration, as well as those of their subscriptions. But why, precisely?
125−
126−The `config` structure contains `src`, a set of partners. These indicate the different sources a circle is currently pulling content from. This allows circles to aggregate messages from multiple places. In doing so, it also receives metadata from those places, hence why we have structures for storing "remote" presences and configurations alongside local ones.
127−
128−Aside from that, `config` contains a description for the circle, which is exactly what it sounds like. It also specifies a `filter`, which are content formatting rules all messages passing through this circle are made to adhere to.
129−
130−Lastly, there's a `control` structure that contains both a security mode and a list of ships, which is either a white- or blacklist depending on the aforementioned mode. There are four such modes available.
131−
132−```hoon
133−++ security :> security mode
134− $? $channel :< blacklist
135− $village :< whitelist
136− $journal :< pub r, whitelist w
137− $mailbox :< our r, blacklist w
138− == ::
139−```
140−
141−A `channel` is publicly readable and writable, with a blacklist for blocking.
142−A `village` is privately readable and writable, with a whitelist for inviting.
143−A `journal` is publicly readable and privately writable, with a whitelist for authors.
144−A `mailbox` is readable by its owner and publicly writable, with a blacklist for blocking.
145−
146−### Stories
147−
148−To see how that all ties together, we're going to take a look at Hall's state.
149−
150−```hoon
151−++ state :> hall state
152− $: stories/(map term story) :< conversations
153− :: ... ::
154− == ::
155−++ story :> wire content
156− $: grams/(list telegram) :< all messages
157− locals/group :< local presence
158− remotes/(map circle group) :< remote presence
159− shape/config :< configuration
160− mirrors/(map circle config) :< remote config
161− :: ... ::
162− == ::
163−```
164−
165−Stories are the primary driver behind Hall. They are the structures that are used to power circles, which we can now say are named stories hosted on ships.
166−
167−With the configuration described above in mind, we can try and imagine the things we can do with stories. Knowing that we can subscribe them to any number of sources, they can function as central hubs for our messaging, aggregate specific kinds of data feeds, or simply accept whatever messages get sent to it like a regular old chatroom.
168−
169−### General use
170−
171−Upon initial startup, Hall creates a default story, a mailbox named `inbox`. This mailbox is the primary target for anyone and anything that wants to reach its owner. Applications can use it to send notifications and other information to the user (Hall itself does this as well), and users can use it to send direct messages to each other.
172−
173−Applications that use Hall, especially clients, are encouraged to use the default mailbox as the primary messaging hub. This way, users can easily switch between different applications without "losing" their subscriptions, message backlog, etc.
174−
175−As an example, Talk operates like this, serving as an interface for reading from and managing the user's mailbox. Local stories are subscribed to through the `inbox`, which ends up containing all messages the user receives.
176−
177−### Public membership
178−
179−To aid in discoverability of circles, it is possible for users to make their participation in any given circle public. This data can then be used by things like profile widgets, or read out directly by other users.
180−
181−
182−## Interfaces for applications
183−
184−Applications can interact with Hall in two complementary ways: they can tell it what actions to perform, and they can subscribe to its state and the changes made to it.
185−
186−### Interactions
187−
188−Hall can be commanded by poking it with `action`s.
189−
190−```hoon
191−++ action :> user action
192− $% :: circle configuration ::
193− {$create nom/term des/cord sec/security} :< create circle
194− {$delete nom/term why/(unit cord)} :< delete + announce
195− {$depict nom/term des/cord} :< change description
196− {$filter nom/term fit/filter} :< change message rules
197− {$permit nom/term inv/? sis/(set ship)} :< invite/banish
198− {$source nom/term sub/? srs/(set source)} :< un/sub to/from src
199− :: messaging ::
200− {$convey tos/(list thought)} :< post exact
201− {$phrase aud/audience ses/(list speech)} :< post easy
202− :: personal metadata ::
203− {$notify aud/audience pes/(unit presence)} :< our presence update
204− {$naming aud/audience man/human} :< our name update
205− :: changing shared ui ::
206− {$glyph gyf/char aud/audience bin/?} :< un/bind a glyph
207− {$nick who/ship nic/cord} :< new identity
208− :: misc changes ::
209− {$public add/? cir/circle} :< show/hide membership
210− == ::
211−```
212−
213−The largest part of these actions concern themselves with managing local circles. `nom` is always the name used to identify the relevant story. To disambiguate between "add" and "delete" type actions (for permissions and subscriptions), a loob `?` is used.
214−
215−To send messages, two interfaces are available. `%convey` lets you specify all details of the messages, including its timestamp, serial, and fully assembled audience. `%phrase`, on the other hand, takes care of that for you, allowing you to specify just the target partners and message contents.
216−
217−`%notify` and `%naming` are useful for setting your own presence and nickname in a circle respectively, so others can see if you're active and what to call you by.
218−
219−"Shared UI" encompasses UI data that should be consistent across applications. For example, if the user sets a local nickname for an identity, they expect to see that nickname regardless of the application they're currently using. The same goes for glyph bindings, for easy audience targeting.
220−
221−### Queries, prizes and rumors
222−
223−To receive data from Hall, applications will have to query it. There are two paths that are useful for clients to query. Let's look at them and their results.
224−
225−```hoon
226−++ query :> query paths
227− $% {$client $~} :< shared ui state
228− $: $circle :> story query
229− nom/naem :< circle name
230− wat/(set circle-data) :< data to get
231− ran/range :< query duration
232− == ::
233− :: ... ::
234− == ::
235−++ circle-data :> kinds of circle data
236− $? $grams :< messages
237− $group-l :< local presence
238− $group-r :< remote presences
239− $config-l :< local config
240− $config-r :< remote configs
241− == ::
242−++ range :> inclusive msg range
243− %- unit :< ~ means everything
244− $: hed/place :< start of range
245− tal/(unit place) :< opt end of range
246− == ::
247−++ place :> range indicators
248− $% {$da @da} :< date
249− {$ud @ud} :< message number
250− == ::
251−++ prize :> query result
252− $% $: $client :< /client
253− gys/(jug char (set partner)) :< glyph bindings
254− nis/(map ship cord) :< nicknames
255− == ::
256− {$circle burden} :< /circle
257− :: ... ::
258− == ::
259−++ burden :< full story state
260− $: gaz/(list telegram) :< all messages
261− cos/lobby :< loc & rem configs
262− pes/crowd :< loc & rem presences
263− == ::
264−```
265−
266−To be clear, the paths for those queries are `/client` and `/circle/[name]/[data]/[start]/[end]`, where data is at least one `circle-data`, and `start` and `end` are optional and can be either a date or a message number.
267−
268−`/client` queries produce shared UI state. That is, glyph bindings and nicknames.
269−`/circle` queries produce the entire public state of the requested story, including remotes.
270−
271−Any changes to the results of these queries are communicated via the following `rumor`s. It's a fairly long list of potential changes,
272−
273−```hoon
274−++ rumor :< query result change
275− $% {$client rum/rumor-client} :< /client
276− {$circle rum/rumor-story} :< /circle
277− :: ... ::
278− == ::
279−++ rumor-client :< changed ui state
280− $% {$glyph diff-glyph} :< un/bound glyph
281− {$nick diff-nick} :< changed nickname
282− == ::
283−++ diff-glyph {bin/? gyf/char aud/audience} :< un/bound glyph
284−++ diff-nick {who/ship nic/cord} :< changed nickname
285−++ diff-story :> story change
286− $% {$new cof/config} :< new story
287− {$config cir/circle dif/diff-config} :< new/changed config
288− {$status cir/circle who/ship dif/diff-status} :< new/changed status
289− {$remove $~} :< removed story
290− :: ... ::
291− == ::
292−++ rumor-story ::> story rumor
293− $? diff-story ::< both in & outward
294− $% {$gram nev/envelope} ::< new/changed msgs
295− == == ::
296−++ diff-config :> config change
297− $% {$full cof/config} :< set w/o side-effects
298− {$source add/? src/source} :< add/rem sources
299− {$caption cap/cord} :< changed description
300− {$filter fit/filter} :< changed filter
301− {$secure sec/security} :< changed security
302− {$permit add/? sis/(set ship)} :< add/rem to b/w-list
303− {$remove $~} :< removed config
304− == ::
305−++ diff-status :> status change
306− $% {$full sat/status} :< fully changed status
307− {$presence pec/presence} :< changed presence
308− {$human dif/diff-human} :< changed name
309− {$remove $~} :< removed status
310− == ::
311−++ diff-human :> name change
312− $% {$full man/human} :< fully changed name
313− {$handle han/(unit cord)} :< changed handle
314− {$true tru/(unit truename)} :< changed true name
315− == ::
316−```
317−
318−These are, as enforced by Gall, the changes as they happen. This makes it possible for very minimal Hall clients to be implemented that only display a stream of changes, rather than keeping state themselves.
319−
320−
321−## Communication between Halls
322−
323−Halls can communicate with other Halls by sending commands and subscription updates.
324−
325−### Commands
326−
327−To request changes to a story, Halls can send `command`s.
328−
329−```hoon
330−++ command :> effect on story
331− $% {$publish tos/(list thought)} :< deliver
332− {$present nos/(set term) dif/diff-status} :< status update
333− :: ... ::
334− == ::
335−```
336−
337−A `%publish` command contains messages. These are sent to foreign Halls to be published to their stories.
338−
339−The `%present` command is used for sending status updates about our ship.
340−
341−### Querying
342−
343−Halls can query other halls. Here's the peer move we send when we open a query on a foreign circle:
344−
345−```hoon
346−:* ost.bol :< bone
347− %peer :< move type
348− /[our-circle]/[host]/[query-path] :< rumor path
349− [host %hall] :< query target
350− /circle/[their-circle]/[data]/[start]/[end] :< query path
351−== ::
352−```
353−
354−Again, the rumor path is what our Hall uses to identify what query a received message originates from. Our circle is specified so that we know what story is interested in the changes we get.
355−
356−The query path is slightly more interesting. Of course it specifies the name of their story we want to subscribe our story to, but also a "start" and "end". These can (optionally) be used to specify the range of messages we want to get from our query. Once that range has passed, we stop receiving updates.
357−
358−### Federation implementation
359−
360−Along the way so far, we've skipped some parts of structures. Most of those relate to federation. Let's see what we missed.
361−
362−```hoon
363−++ query :> query paths
364− $% {$burden who/ship} :< duties to share
365− {$report $~} :< duty reports
366− :: ... ::
367− == ::
368−++ prize :> query result
369− $% {$burden sos/(map term burden)} :< /burden
370− :: ... ::
371− == ::
372−++ rumor :< query result change
373− $% {$burden nom/term rum/rumor-story} :< /burden
374− :: ... ::
375− == ::
376−++ diff-story ::
377− $% {$bear bur/burden} :< new inherited story
378− :: ... ::
379− == ::
380−++ burden :> full story state
381− $: gaz/(list telegram) :< all messages
382− cos/lobby :< loc & rem configs
383− pes/crowd :< loc & rem presences
384− == ::
385−```
386−
387−We briefly touched upon how federation works on the higher level. On the lower, this is how things go down.
388−
389−1. When Hall boots on a star or galaxy, it starts querying its parent's `/burden` path. (Galaxies query ~zod.)
390−2. Upon receiving that query, the parent sends a `%burden` prize containing all state of its channels (fully public circles) to the child. It also subscribes to `/report` on that child.
391−3. When a new story gets created on the parent, its children get a `%burden` rumor with a `%bear` story diff, and they create a local copy of that channel.
392−4. When something about a parent's story changes, a `%burden` rumor is sent to all its children (because they're querying `/burden`). The children apply this change to their local version of the story.
393−5. When a child's story has a `%grams` or `%status` change, a `%burden` rumor is sent to the parent (because they're querying `/report`). The parent applies this change to their local version of the story, and #4 happens.
394−
395−
396−## Hall implementation
397−
398−Now that we know what gets sent over the wire and why, let's see what happens whenever such events happen. We won't be covering everything, but enough to illustrate the general flow.
399−
400−First though, it's useful to understand how Hall's code is structured. It consists of primary cores, designed to work optimally with Gall.
401−
402−- `++ta` is the transaction core. For every event that happens, be it a poke, peer or diff, the transaction core gets put to work to process it. Once it's done, it produces a list of deltas that describe how our state needs to be modified.
403−- `++da` is the delta application core. It is used to apply `++ta`'s deltas to our application state, and produce a list of side-effects.
404−
405−Both those cores also have a core within themselves dedicated solely to dealing with stories, `++so` and `++sa` respectively.
406−
407−Once all work in an engine core has finished, its `-done` arm is called to produce the result of all the core's computation.
408−
409−In the diagrams that follow, regular lines indicate flows that always happen. Dashed lines indicate flows that are traversed if the described condition is met.
410−Below the diagrams you will find brief explanations of the involved arms. In a particularly bright future, these might be available on-hover instead.
411−For brevity, utility arms that aren't a direct and important part of the flow have been omitted.
412−
413−(You will find that the origins still use old Gall arms, with some glue code in between. At the time of writing, new Gall has not yet been implemented, so this will have to do.)
414−
415−We will only display the delta generation parts of the flow. Delta application is usually implemented simply enough to deduce what it does from looking at the label.
416−
417−### Subscriptions
418−
419−Hall-to-Hall subscriptions happen when a source gets added to a story. This is done with a `%source` action, and results in a `%peer` move being sent (prompted by a `%story %follow` delta).
420−Upon receiving a valid peer on a `/circle` path, the subscribing ship is added to that circle's presence map.
421−
422−![subscriptions implementation flow](https://media.urbit.org/docs/hall/diagrams/flow-subscriptions.png)
423−
424−```hoon
425−++ poke-talk-action :< we got poked with an action.
426− ++ ta-action :< applies an action.
427− ++ ta-config :< (re)configures a story.
428−:: ::
429−++ peer :< we got peered.
430− ++ g-query :< resolves query to prize.
431− ++ ta-subscribe :< act upon subscription.
432− ++ so-attend :< adds a ship's status to the story.
433−```
434−
435−### Rumors
436−
437−Once a query has opened, Hall will receive updates on it, rumors. The changes describes in these rumors are applied via the following flow.
438−
439−![rumor implementation flow](https://media.urbit.org/docs/hall/diagrams/flow-rumors.png)
440−
441−```hoon
442−++ diff-talk-rumor :< we got a query update.
443− ++ ta-hear :< applies a rumor to the story it's intended for.
444− ++ so-hear :< applies a %circle rumor to the story.
445− ++ so-config-full :< splits a %full diff-config into separate changes.
446− ++ so-bear :< accept burden, assimilate into the story's state.
447− ++ so-lesson :< sends a report with presences.
448−```
449−
450−### Messaging
451−
452−To send messages, the user sends a `%convey` or `%phrase` action, resulting in a `%publish` command being sent to the involved partners. Receiving a `%publish` command causes its messages to be added to the story through the creation of a `%story %grams` delta.
453−
454−![messaging implementation flow](https://media.urbit.org/docs/hall/diagrams/flow-messaging.png)
455−
456−```hoon
457−++ poke-talk-action :< we got poked with an action.
458− ++ ta-action :< applies an action.
459−:: ::
460−++ poke-talk-command :< we get poked with a command.
461− ++ ta-apply :< applies a command.
462− ++ ta-think :< consumes each message in the given list.
463− ++ ta-consume :< conducts a message to each partner in audience.
464− ++ ta-conduct :< records or sends a message.
465− ++ ta-transmit :< sends a message to a partner.
466− ++ ta-record :< stores a message in a story.
467− ++ so-learn :< either adds or modifies a message.
468−```
469−
470−
471−## The future
472−
473−Hall is neither complete nor perfect. There are features that need to be implemented, varying from small quality of life changes to broad-reaching functionality.
474−
475−### Features and functionality
476−
477−To turn Talk into a [sustainable social platform](https://urbit.org/fora/posts/~2017.4.26..18.00.25..b93c~/), it needs a number of things.
478−
479−We want to have some kind of discoverability for circles. This could be realized by making it possible for users to add friends, who would have their Hall subscribe to a list of circles the added friends are in. The existing public membership functionality can be leveraged for this.
480−
481−Eventually, content self-moderation might need to be implemented. Users would flag their content if it is potentially offensive. Others would easily be able to filter out content that might offend them.
482−This functionality brings its own large sets of challenges that need to be tackled.
483−
484−Additionally, federation might be put to broader use. Knowing that a circle is federated could help fall back to alternative hosts in case the one Hall originally subscribed to is unavailable. Implementation-wise, care would need to be taken for this to not get ugly. Not to mention, when/how would availability of a host be verified?
485−
486−Other changes that might have a fair impact on the functioning of Hall are un/read states for messages, and being able to use moons to allow your friends to chat with you in a local channel.
487−
488−More minor functionalities that need to be implemented include:
489−- Extended permissions management. Being able to black-/whitelist entire ship classes.
490−- Improved presence functionality. Actually using the presence system, and sending "typing", "idle", etc. statuses.
491−- Polls.
492−
493−And, of course, there's a lot that the Talk client can improve on as well.
494−
495−
496−## Further reading
497−
498−To gain a more thorough understanding of Hall's inner workings, take a look at its source code. It comes with inline documentation.
499−[On Github.](https://github.com/urbit/urbit/blob/master/pkg/arvo/app/hall.hoon)
500−
501−To see an expansive example of a Hall client, take a look at the code of Talk. It, too, comes with inline documentation.
502−[On Github.](https://github.com/urbit/urbit/blob/master/pkg/arvo/app/talk.hoon)
503−
504−# The Hall Interface
505−
506−This document describes the different interfaces Hall provides and the data that is accessible and modifiable through them. Knowledge of the Urbit application model (including [new gall](#the-new-gall-model)) and [Hall's architecture](#hall-architecture) is assumed.
507−
508−While the structures here are given in Hoon, they match fairly closely to their JSON equivalent. Most important to note is that `$%({$x y/z})` becomes accessible as `json.x.y`.
509−
510−## Queries
511−
512−Queries are the paths you pass into `%peer` moves. Internally, they get translated to a `++query` structure for easier handling. We'll be giving examples of valid query paths alongside the structures themselves.
513−
514−### /client
515−
516−To be able to keep certain UI elements like glyphs and local nicknames consistent across different Hall clients, they can query Hall for the current UI state.
517−
518−```hoon
519−++ query ::
520− $% {$client $~} :< shared ui state
521− :: .... ::
522− == ::
523−```
524−
525−Valid paths include:
526−
527−```
528−:> all shared ui state
529−/client
530−```
531−
532−#### /client prize
533−
534−Contains a map of glyphs and the audiences that they map to, as well as a map of ships and their locally set nicknames.
535−
536−```hoon
537−++ prize :> query result
538− $% {$client prize-client} :< /client
539− :: ... ::
540− == ::
541−++ prize-client :> shared ui state
542− $: gys/(jug char audience) :< glyph bindings
543− nis/(map ship nick) :< local nicknames
544− == ::
545−```
546−
547−#### /client rumor
548−
549−Contains either a bound or unbound glyph and its target, or a ship with its new nickname. A nickname of `''` means the associated ship no longer has a nickname set for it.
550−
551−```hoon
552−++ rumor :> query result change
553− $% {$client rum/rumor-client} :< /client
554− :: ... ::
555− == ::
556−++ rumor-client :< changed ui state
557− $% {$glyph diff-glyph} :< un/bound glyph
558− {$nick diff-nick} :< changed nickname
559− == ::
560−++ diff-glyph {bin/? gyf/char aud/audience} :< un/bound glyph
561−++ diff-nick {who/ship nic/nick} :< changed nickname
562−```
563−
564−
565−### /public
566−
567−To aid in circle discoverability, users can add circles to their "public membership" list. This can then be queried for by, for example, a profile page.
568−
569−```hoon
570−++ query ::
571− $% {$public $~} :< public memberships
572− :: .... ::
573− == ::
574−```
575−
576−Valid paths include:
577−
578−```
579−:> all public memberships
580−/public
581−```
582−
583−#### /public prize
584−
585−Contains the set of circles the user has on their public list.
586−
587−```hoon
588−++ prize :> query result
589− $% {$public cis/(set circle)} :< /public
590− :: ... ::
591− == ::
592−```
593−
594−#### /public rumor
595−
596−Contains a circle that was either added or removed from the public list.
597−
598−```hoon
599−++ rumor :> query result change
600− $% {$public add/? cir/circle} :< /public
601− :: ... ::
602− == ::
603−```
604−
605−### /peers
606−
607−To allow a circle owner to inspect who is currently subscribed to their stories, they can issue a query to retrieve subscription data.
608−
609−```hoon
610−++ query ::
611− $% {$peers nom/naem} :< readers of story
612− :: .... ::
613− == ::
614−```
615−
616−Query paths are structured as follows:
617−
618−```
619−/peers/[circle-name]
620−```
621−
622−Valid paths include:
623−
624−```
625−:> peers for circle %urbit-help
626−/peers/urbit-help
627−```
628−
629−#### /peers prize
630−
631−Contains a map of ships and the different queries they currently have active for the selected story.
632−
633−```hoon
634−++ prize :> query result
635− $% {$peers pes/(jar ship query)} :< /peers
636− :: ... ::
637− == ::
638−```
639−
640−#### /peers rumor
641−
642−Contains a ship and a query, and a flag to indicate whether that subscription has started or ended.
643−
644−```hoon
645−++ rumor :> query result change
646− $% {$peers add/? who/ship qer/query} :< /peers
647− :: ... ::
648− == ::
649−```
650−
651−### /circle
652−
653−Circle queries allow for the retrieving of data from stories. Their messages, configuration, and presences can all be accessed. Since this is a lot of data, there are lots of possibilities for filtering it built in to the query itself.
654−
655−
656−A quick refresher on the difference between "local" and "remote" presence and configuration: "local" means it pertains to the circle itself; "remote" means it pertains to one of its configured sources. The latter is primarily useful to clients when using a circle for aggregation, like the `%inbox`.
657−
658−```hoon
659−++ query ::
660− $% $: $circle :> story query
661− nom/naem :< circle name
662− wer/(unit circle) :< from source
663− wat/(set circle-data) :< data to get
664− ran/range :< query duration
665− == ::
666− :: .... ::
667− == ::
668−++ circle-data :> kinds of circle data
669− $? $grams :< messages
670− $group-l :< local presence
671− $group-r :< remote presences
672− $config-l :< local config
673− $config-r :< remote configs
674− == ::
675−++ range :> inclusive msg range
676− %- unit :< ~ means everything
677− $: hed/place :< start of range
678− tal/(unit place) :< opt end of range
679− == ::
680−++ place :> range indicators
681− $% {$da @da} :< date
682− {$ud @ud} :< message number
683− == ::
684−```
685−
686−Query paths are structured as follows:
687−
688−```
689−/circle/[circle-name]/(from-circle)/[what/data]/(range-start(/range-end))
690−(from-circle) : optional message source, ~ship/circle
691−[what/data] : one or more of grams, group, group-l, group-r,
692− : config, config-l, config-r, combined using /
693−(range) : an optional range with an optional end, its points denoted
694− : in either message number (@ud) or date (@da)
695−```
696−
697−Valid paths include:
698−
699−```
700−:> get all messages from circle %urbit-help
701−/circle/urbit-help/grams
702−:> get all messages, all presences and local configs from %urbit-help
703−/circle/urbit-help/grams/group/config-l
704−:> get all messages %urbit-help has heard from its source ~zod/fora
705−/circle/urbit-help/~zod/fora/grams
706−:> get the first 100 messages from %urbit-help
707−/circle/urbit-help/grams/0/99
708−:> get the first 100 messages %urbit-help has heard from its source ~zod/fora
709−/circle/urbit-help/~zod/fora/grams/0/99
710−:> get all messages from %urbit-help, starting now
711−/circle/urbit-help/grams/group/(scow %da now)
712−:> get all messages from %urbit-help, starting now, ending at the 100th message
713−/circle/urbit-help/grams/(scow %da now)/99
714−:> get local presences from %urbit-help for a week
715−/circle/urbit-help/group-l/(scow %da now)/(scow %da (add now ~d7))
716−```
717−
718−#### /circle prize
719−
720−Contains (where applicable) messages in envelopes (with message numbers), as well as local and remote configurations and presences.
721−
722−```hoon
723−++ prize :> query result
724− $% {$circle package} :< /circle
725− :: ... ::
726− == ::
727−++ package :> story state
728− $: nes/(list envelope) :< messages
729− cos/lobby :< loc & rem configs
730− pes/crowd :< loc & rem presences
731− == ::
732−```
733−
734−#### /circle rumor
735−
736−Contains a detailed change description of the data relevant to the query that changed.
737−
738−Messages are wrapped in envelopes to include their sequence number, and note the source they were heard from. Configuration and status changes specify the circle they apply to.
739−
740−```hoon
741−++ rumor :> query result change
742− $% {$circle rum/rumor-story} :< /circle
743− :: ... ::
744− == ::
745−++ rumor-story :> story rumor
746− $% {$new cof/config} :< new story
747− {$gram src/circle nev/envelope} :< new/changed message
748− {$config cir/circle dif/diff-config} :< new/changed config
749− {$status cir/circle who/ship dif/diff-status} :< new/changed status
750− {$remove $~} :< removed story
751− == ::
752−++ diff-config :> config change
753− $% {$full cof/config} :< set w/o side-effects
754− {$source add/? src/source} :< add/rem sources
755− {$caption cap/cord} :< changed description
756− {$filter fit/filter} :< changed filter
757− {$secure sec/security} :< changed security
758− {$permit add/? sis/(set ship)} :< add/rem to b/w-list
759− {$remove $~} :< removed config
760− == ::
761−++ diff-status :> status change
762− $% {$full sat/status} :< fully changed status
763− {$presence pec/presence} :< changed presence
764− {$human dif/diff-human} :< changed name
765− {$remove $~} :< removed status
766− == ::
767−++ diff-human :> name change
768− $% {$full man/human} :< fully changed name
769− {$handle han/(unit cord)} :< changed handle
770− {$true tru/(unit truename)} :< changed true name
771− == ::
772−```
773−
774−
775−## Actions
776−
777−Actions can be sent by poking Hall with data marked as `%hall-action`. Actions are used for all user operations. If an error or other unexpected behavior occurs while executing an action, Hall notifies the user by sending an `%app` message to their `%inbox`.
778−
779−### Circle configuration
780−
781−Since all of these apply to a specific circle, they all specify a name `nom` of the circle to operate on.
782−
783−```hoon
784−++ action :> user action
785− $% {$create nom/naem des/cord sec/security} :< create circle
786− {$delete nom/naem why/(unit cord)} :< delete + announce
787− {$depict nom/naem des/cord} :< change description
788− {$filter nom/naem fit/filter} :< change message rules
789− {$permit nom/naem inv/? sis/(set ship)} :< invite/banish
790− {$source nom/naem sub/? srs/(set source)} :< un/sub to/from src
791− :: ... ::
792− ==
793−```
794−
795−`%create`: Creates a circle with description `des` and security mode `sec`. If this mode is a whitelist, the user is automatically added to it.
796−
797−`%delete`: Deletes the circle. If a reason `why` is provided, posts that as the last message to the circle before deleting it.
798−
799−`%depict`: Set the description of the circle to `des`.
800−
801−`%filter`: Set the filter (message sanitation rules) for the circle to `fit`.
802−
803−`%permit`: Either invite or banish ships to/from the circle, modifying the access control list accordingly. Regardless of whether this actually makes any changes, sends an `%inv` message to the involved ships' `%inbox`es.
804−
805−`%source`: Add or remove sources to/from the circle, un/subscribing it to/from the `grams`, `group-l` and `config-l` each one.
806−
807−### Messaging
808−
809−There are two interfaces for telling Hall to send a message. The first takes entire `thought`s, the second only `speech`es and the audience to send them to.
810−
811−```hoon
812−++ action :> user action
813− $% {$convey tos/(list thought)} :< post exact
814− {$phrase aud/audience ses/(list speech)} :< post easy
815− :: ...
816− ==
817−```
818−
819−`%convey`: Sends the thoughts to their audiences.
820−
821−`%phrase`: Turns the speeches into thoughts by applying sane defaults for metadata (auto-generated `uid`, `now` for `wen`), and then sends those thoughts.
822−
823−### Personal metadata
824−
825−These concern the presence users have in circles they are participating in.
826−
827−```hoon
828−++ action :> user action
829− $% {$notify aud/audience pes/(unit presence)} :< our presence update
830− {$naming aud/audience man/human} :< our name update
831− :: ... ::
832− ==
833−```
834−
835−`%notify`: Sets the user's presence in the audience circles to `pes`. A good client will automatically set these based on the user's activity. (`%talk` on typing, `%idle` on idle, `%gone` on sign-off.)
836−
837−`%naming`: Sets the user's name (handle and real name) for the given audience. Good clients can display these in place of ship names.
838−
839−### Changing shared UI
840−
841−When the user makes any changes to shared UI elements (elements that should persist between clients), this has to be communicated to Hall.
842−
843−```hoon
844−++ action :> user action
845− $% {$glyph gyf/char aud/audience bin/?} :< un/bind a glyph
846− {$nick who/ship nic/nick} :< new identity
847− :: ... ::
848− ==
849−```
850−
851−`%glyph`: Adds or removes a binding of a glyph to an audience.
852−
853−`%nick`: Sets a local nickname for a ship. An empty nickname `''` means the ship has no nickname.
854−
855−### Miscellaneous changes
856−
857−```hoon
858−++ action :> user action
859− $% {$public add/? cir/circle} :< show/hide membership
860− :: ... ::
861− ==
862−```
863−
864−`%public`: Adds or removes a circle to/from the user's public membership list.
865−
866−# The New Gall Model
867−
868−This document is complemented by the source code of applications that use the new Gall model (like [Hall](https://github.com/urbit/urbit/blob/master/pkg/arvo/app/hall.hoon)), but doesn't require it. Code snippets will be provided where useful. Some knowledge of Hoon and the functioning of Hoon apps is assumed.
869−
870−New `%gall` has not yet fully solidified. As such, its structure and naming are tentative.
871−
872−## Renewing a pillar of Arvo
873−
874−When you write an app, Gall is responsible for making sure its event arms like `++poke` get called when they need to. In essence, it provides developers with a consistent interface for hooking their app up to the operating system.
875−
876−It's not doing a lot to make sure this is done in a structured way, though, which results in apps (especially larger ones) feeling like big, tangled messes. Something needs to be done about this.
877−
878−### Problems
879−
880−Imagine a `++poke`, `++diff`, or even a `++peer` arm. In current implementations, you'll often see their product defined through cast as the following:
881−`^- (quip move +>)`
882−Or (sadly) more commonly:
883−`^- {(list move) _+>.$}`
884−
885−These arms are producing both side-effects and new state. To do this, their code has to simultaneously figure out "how does this poke/diff/whatever change our state?" and "what side-effects does this change have?"
886−
887−You'll find that the logic relating to these two often becomes tangled, making the flow of the whole more difficult to understand. And the side-effects more often than not relate to subscriptions, for which the developer may be writing a lot of boilerplate code. Gall currently does not help in either of these places.
888−
889−> The main significant cost of software development is the cost of untangling what the computer is doing, and or is supposed to be doing, over and over again in your head. Any way of lowering this untangling cost is extremely welcome.
890−
891−**~sorreg-namtyv**
892−
893−### Solutions
894−
895−Let's imagine a world in which Gall **does** help, in both of those places.
896−
897−It would be wonderful if Gall could take care of all standard subscription management logic for you, and direct the flow of code as it concludes is appropriate. Applications, then, would have to help Gall by providing the different parts of this flow, and providing the checks that allow Gall to make the right decisions. This takes some work out of the developer's hands and results in more structured application code.
898−
899−If we expand on that a bit, then we can even have Gall help us in untangling state changes from side effects. We do so by separating state changes into two phases: **analyzing** what changes need to be made, and **applying** those changes.
900−
901−But where do the side-effects go, then? We need to realize there's two kinds: side-effects that are subscription updates, and side-effects that aren't. The latter get produces by applying state changes, while the former get integrated into the Gall flow we described above.
902−
903−Since subscriptions are essentially queries to an app, requesting a specific part of its data/state, we can deduce subscription updates from state changes. We merely provide the logic, and Gall chains it all together. Having Gall support all this allows us to cleanly and structurally untangle state change analysis, application, and subscription logic into their own arms.
904−
905−For trivial apps, this might result in some arms with trivial code. Though it may feel like writing cruft, it makes understanding the app just as simple as it actually as. For more complex apps, all logic is no longer a big chunk of "what do we do when x happens?" Rather, it's a few smaller chunks, like "x happened, how does that change our state?" and "if our state changes like y, what does that mean for subscription z?" These are precisely the kinds of questions that application developers should be asked.
906−
907−
908−## As seen in new Gall
909−
910−Of course, for the above to be made into reality, Gall will need to see some changes. Let's outline the new structures and the arms they get passed between.
911−
912−### Structures
913−
914−This wouldn't be Urbit if we didn't have cool terminology for people to learn. These ones are (for the most part) semantically sensible, and you might already see how they relate to the story above.
915−
916−`brain`: application state.
917−`delta`: change to application state.
918−`opera`: side-effect, operation, move.
919−`query`: request (to an app) for data on a specific path.
920−`prize`: query result.
921−`rumor`: change to a query result.
922−
923−These should be fairly straightforward. Like packets are to Urbits, `delta`s are to `brain`s and `rumor`s are to `prize`s. If one diligently updates the `prize` they received using all the `rumor`s that are relevant to it, they will always have the same `prize` as if they queried for it all over again.
924−
925−### Arms
926−
927−This also wouldn't be Urbit if we couldn't boil that down to a few simple pseudocode functions. Let's try, shall we?
928−
929−```hoon
930−++ bake |= {brain delta} ^- {brain opera}
931−++ peek |= {brain query} ^- (unit (unit prize))
932−++ feel |= {query delta} ^- (unit rumor)
933−++ gain |= {prize rumor} ^- prize
934−
935−:: for any given brain, delta and query:
936−.= (peek brain:(bake brain delta) query)
937− (gain rumor:(feel query delta) prize:(peek brain query))
938−```
939−
940−There. In the first three arms we already have the bulk of new Gall! `++gain` won't be part of it, since most applications don't need to keep track of `prize`s directly. Those that do may still implement and hook it up themselves though.
941−
942−Of course, these aren't all of the new Gall arms. Most important to still mention is `++leak`, which takes a `ship` and `query` and checks if the former has permission to ask for the latter.
943−
944−There's also `++look` for asynchronous reads, `++hear` for subscription updates (rumors), `++fail` for dealing with process errors, `++cope` for dealing with transaction results, and `++pour` for dealing with responses from Arvo.
945−`++prep`, `++poke` and `++pull` continue to function as they do right now.
946−
947−For a more verbose specification of all of these, see the new Gall spec.
948−
949−
950−## By example
951−
952−To help solidify this and see what this would looks like in the wild, let's make a very simple example app. It's a counter that can go up and down, and can be queried for its value, or whether or not its value is a multiple of x. First we write all the structures that will support our app, and then we implement the arms that operate on them.
953−(The app code in its entirety can be found [here](example).)
954−
955−### State & deltas
956−
957−Below is the application state, and the deltas we'll be using to modify it.
958−
959−```hoon
960−|%
961−++ brain {num/@ud $~} :< application state
962−++ delta :> state change
963− $% {$increment $~} :< +1
964− {$decrement $~} :< -1
965− == ::
966−```
967−
968−Fairly simple, right? We store a number, and every change either in- or decrements it.
969−
970−### Queries & rumors
971−
972−Let's also define the queries we'll be supporting, their results, and the changes to their results. Instead of only allowing people to query the current number, let's make it a tad more interesting by allowing them to query whether or not the current number is a multiple of something.
973−
974−```hoon
975−++ query :> valid queries
976− $% {$number $~} :< current number
977− {$mul-of val/@ud} :< is num multiple of?
978− == ::
979−++ prize :> query results
980− $% {$number num/@ud} :< /number
981− {$mul-of mul/?} :< /mul-of
982− == ::
983−++ rumor :> query result changes
984− $% {$number delta} :< /number
985− {$mul-of mul/?} :< /mul-of
986− == ::
987−--
988−```
989−
990−You'll see the `rumor` for a `/number` query just contains a delta. In this specific case, a change in state maps directly to a change to `prize`. For `/mul-of` queries, things aren't that simple.
991−
992−### Responding to queries
993−
994−Now, let's implement all the arms that will be called as things start happening. First, we want to implement `++leak`, which checks if a given `ship` is allowed to make a certain `query`. In this case, we're fine with everyone checking out our application's data.
995−
996−```hoon
997−|_ {bol/bowl brain}
998−::
999−++ leak :> read permission
1000− |= {who/ship qer/query}
1001− ^- ?
1002− & :: everyone's allowed
1003−```
1004−
1005−Next, let's create the `prize`s for the folks that make it through `++leak`. We'll be producing a `(unit (unit prize))` so we can potentially say `~` for "unavailable" and `[~ ~]` for "invalid query."
1006−
1007−```hoon
1008−++ peek :> synchronous read
1009− |= qer/query
1010− ^- (unit (unit prize))
1011− ?- -.qer
1012− $number ``[%number num]
1013− $mul-of ?: =(0 mul.qer) [~ ~]
1014− ``[%mul-of =(0 (mod num mul.qer))]
1015− ==
1016−```
1017−
1018−
1019−### Updating state & query results
1020−
1021−Our app can be queried! If they're interested enough, they'll want to receive updates on that whenever relevant state changes. First, let's see how state changes happen. We still have regular old `++poke` arms, let's use that to prompt our application to change its state.
1022−
1023−```hoon
1024−++ poke-loob :> regular old poke
1025− |= inc/?
1026− ^- (list delta)
1027− :_ ~
1028− ?: inc [%increment ~]
1029− [%decrement ~]
1030−::
1031−++ bake :> apply delta to state
1032− |= del/delta
1033− ^- (quip opera +>)
1034− :- ~
1035− ?- -.del
1036− $increment +>(num +(num))
1037− $decrement +>(num (dec num))
1038− ==
1039−```
1040−
1041−`delta`s get redirected into `++bake` so that our state can get changed as described. After this happens the same `delta`s get, for each active query, routed into `++feel`. That then figures out what the `rumor` relevant to the query is, if applicable.
1042−
1043−```hoon
1044−++ feel :> delta to rumor
1045− |= {qer/query del/delta}
1046− ^- (unit rumor)
1047− ?- -.qer
1048− $number
1049− `[%number del]
1050− ::
1051− $mul-of
1052− :: since we only want to send a rumor if result
1053− :: changed, we need to deduce the old state from
1054− :: the current state and the delta. depends on the
1055− :: fact that state changes before ++feel. funky!
1056− :: we could, of course, store mul/? in state, and
1057− :: make a delta for it, but should we need to?
1058− =/ old
1059− .= 0
1060− %+ mod
1061− ?- -.del
1062− $increment (dec num)
1063− $decrement +(num)
1064− ==
1065− mul.qer
1066− =/ new =(0 (mod num mul.qer))
1067− ?: =(old new) ~
1068− `[%mul-of new]
1069− ==
1070−```
1071−
1072−As we saw earlier, for `/number` queries the `delta`s match one-on-one with the relevant `rumor`s. For `/mul-of` queries we do a little bit of work to see if anything actually changed. No need to send a `rumor` if it hasn't.
1073−
1074−
1075−## Criticism
1076−
1077−- Where event arms currently get passed a `wire`, and the new Gall described above passes them a custom `query` structure, the original new Gall spec gave them `(list coin)`, a "pre-parsed wire". These structures (eg `[%$ p=[p=~.ud q=123]]`) are uncomfortable to work with. Even with a "coin list parsing library" it still doesn't feel ideal. Because of custom structures being easier to work with than lists of `++knot`s or `++coin`s, writing a `++path-to-query` arm by hand is a small cost for huge gains.
1078−
1079−- Why do `prize` units mean what they do? One would expect `~` to mean "invalid" and `[~ ~]` to mean "unavailable" as opposed to the other way around.
1080−
1081−- The original new Gall spec mentions output lists (like `(list delta)` etc.) to be in reverse order. This was done because adding to the head of a list (`[item list]`) is easier than appending to the tail of a list (`(weld list [item ~])` or other). While it's technically easier to produce a list in reverse order, semantically it's yet another thing to keep in mind. Luckily, most of the "add to x, produce all of it later" code is set-and-forget, so probably not a huge deal. But do we really fear a few stray `++flop`s that much?
1082−
1083−- There's some weirdness with relation to relying on old state in `++feel` to determine whether a query result actually changed. Just relying on state in general for delta-to-rumor conversion may or may not violate the new Gall spec.
1084−
1085−- The original new Gall spec specifies `++leak` as taking a `(unit (set ship))`, where `~` means public. Is there a use case for checking more than just a single ship?
1086−
1087−- Gall should probably cache `++feel` results during a single pass, to avoid the cycles of generating what it can be certain of is the same `(unit rumor)`. (But then for eg `/circle/nom/13` and `/circle/nom/14` it would still recalculate. Better than nothing.)
1088−
1089−
1090−## The original new-Gall spec
1091−
1092−`~sorreg-namtyv`
1093−
1094−```hoon
1095−=> |%
1096− --
1097−|* $: :> vinyl: historical state (including version)
1098− :> brain: working state of the application (not including version)
1099− :> delta: grain of change across all state
1100− :> prize: (pair mark noun) for namespace value
1101− :> rumor: (pair mark noun) for namespace diff
1102− :> opera: (pair bone card) for operation (old ++move)
1103− :>
1104− vinyl/mold
1105− brain/mold
1106− delta/mold
1107− prize/mold
1108− rumor/mold
1109− opera/mold
1110− ==
1111−|_ $: :> ops: pending operations, in reverse order
1112− :> ego: current state
1113− :>
1114− ops/(list opera)
1115− ego/brain
1116− ==
1117−:: :: ++bake
1118−++ bake :< apply delta
1119− |= $: :> del: change
1120− :>
1121− del/delta
1122− ==
1123− :> core after change (including operations)
1124− ^- _+>
1125− !!
1126−:: :: ++cope
1127−++ cope :< transaction result
1128− |= $: :> weg: forward identity
1129− :> het: success or error report
1130− :>
1131− weg/(list coin)
1132− het/(unit tang)
1133− ==
1134− :> actions in reverse order
1135− :>
1136− ^- (list delta)
1137− !!
1138−:: :: ++fail
1139−++ fail :< process error
1140− |= $: :> why: error dump
1141− :>
1142− why/tang
1143− ==
1144− :> actions in reverse order
1145− :>
1146− ^- (list delta)
1147− !!
1148−:: :: ++feel
1149−++ feel :< update
1150− |= $: :> del: change
1151− :> pex: preparsed path, inside-first
1152− :>
1153− del/delta
1154− pex/(list coin)
1155− ==
1156− :> query updates in reverse order
1157− :>
1158− ^- (list rumor)
1159− !!
1160−:: :: ++hear
1161−++ hear :< subscription update
1162− |= $: :> weg: forward identity
1163− :>
1164− weg/(list coin)
1165− ==
1166− :> actions in reverse order
1167− :>
1168− ^- (list delta)
1169− !!
1170−:: :: ++pull
1171−++ pull :< subscription cancel
1172− |= $: :> weg: forward identity
1173− :> het: error report, if any
1174− :>
1175− weg/(list coin)
1176− het/(unit tang)
1177− ==
1178− :> actions in reverse order
1179− :>
1180− ^- (list delta)
1181− !!
1182−:: :: ++leak
1183−++ leak :< check access
1184− |= $: :> lec: leakset (~ means public)
1185− :> pex: preparsed path, inside-first
1186− :>
1187− lec/(unit (set ship))
1188− pex/(list coin)
1189− ==
1190− :> if path `pex` is visible to ships in `lec`
1191− ^- ?
1192− !!
1193−:: :: ++load
1194−++ look :< asynchronous read
1195− |= $: :> pex: preparsed path, inside-first
1196− :>
1197− pex/(list coin)
1198− ==
1199− :> actions in reverse order
1200− ^- _+>
1201− !!
1202−:: :: ++prep
1203−++ prep :< load system
1204− |= $: old/vinyl
1205− ==
1206− :> core after boot
1207− ^- _+>
1208− !!
1209−:: :: ++peek
1210−++ peek :< synchronous read
1211− |= $: :> pex: preparsed path, inside-first
1212− :>
1213− pex/(list coin)
1214− ==
1215− :> value at `pec`; ~ for unavailable, [~ ~] for invalid
1216− :>
1217− ^- (unit (unit prize))
1218− !!
1219−:: :: ++poke
1220−++ poke :< generic poke
1221− |= $: :> ost: opaque cause
1222− :> msg: message with mark and vase
1223− :>
1224− ost/bone
1225− msg/cage
1226− ==
1227− :> actions in reverse order
1228− :>
1229− ^- (list delta)
1230− !!
1231−:: :: ++pour
1232−++ pour :< arvo response
1233− |= $: :> weg: forward identity
1234− :> sin: response card
1235− :>
1236− weg/(list coin)
1237− sin/sign
1238− ==
1239− :> actions in reverse order
1240− :>
1241− ^- (list delta)
1242− !!
1243−--
1244−```
1245−
1246−## A new-Gall example app
1247−
1248−```hoon
1249−:: counter app
1250−:: new gall example, may or may not compile.
1251−::
1252−|%
1253−++ query :> valid queries
1254− $% {$number $~} :< current number
1255− {$mul-of val/@ud} :< is num multiple of?
1256− == ::
1257−++ prize :> query results
1258− $% {$number num/@ud} :< /number
1259− {$mul-of mul/?} :< /mul-of
1260− == ::
1261−++ rumor :> query result changes
1262− $% {$number delta} :< /number
1263− {$mul-of mul/?} ::TODO or just flip? :< /mul-of
1264− == ::
1265−:: the above would ordinarily be placed in sur/, ::
1266−:: since other apps might want to use it. ::
1267−++ brain {num/@ud $~} :< application state
1268−++ delta :> state change
1269− $% {$increment $~} :< +1
1270− {$decrement $~} :< -1
1271− == ::
1272−--
1273−::
1274−|_ {bol/bowl brain}
1275−::
1276−++ leak :> read permission
1277− |= {who/ship qer/query}
1278− ^- ?
1279− & :: everyone's allowed
1280−::
1281−++ peek :> synchronous read
1282− |= qer/query
1283− ^- (unit (unit prize))
1284− ?- -.qer
1285− $number ``[%number num]
1286− $mul-of ?: =(0 mul.qer) [~ ~]
1287− ``[%mul-of =(0 (mod num mul.qer))]
1288− ==
1289−::
1290−++ poke-loob :> regular old poke
1291− |= inc/?
1292− ^- (list delta)
1293− :_ ~
1294− ?: inc [%increment ~]
1295− [%decrement ~]
1296−::
1297−++ bake :> apply delta to state
1298− |= del/delta
1299− ^- (quip opera +>)
1300− :- ~
1301− ?- -.del
1302− $increment +>(num +(num))
1303− $decrement +>(num (dec num))
1304− ==
1305−::
1306−++ feel :> delta to rumor
1307− |= {qer/query del/delta}
1308− ^- (unit rumor)
1309− ?- -.qer
1310− $number
1311− `[%number del]
1312− ::
1313− $mul-of
1314− :: since we only want to send a rumor if result
1315− :: changed, we need to deduce the old state from
1316− :: the current state and the delta. depends on the
1317− :: fact that state changes before ++feel. funky!
1318− :: we could, of course, store mul/? in state, and
1319− :: make a delta for it, but should we need to?
1320− =/ old
1321− .= 0
1322− %+ mod
1323− ?- -.del
1324− $increment (dec num)
1325− $decrement +(num)
1326− ==
1327− mul.qer
1328− =/ new =(0 (mod num mul.qer))
1329− ?: =(old new) ~
1330− `[%mul-of new]
1331− ==
1332−::
1333−:: not pictured: ++path-to-query
1334−--
1335−```
azimuth/_index.mddeleted−5
@@ -1,5 +0,0 @@
1−+++
2−title = "Azimuth"
3−weight = 1
4−template = "sections/docs/chapters.html"
5−+++
azimuth/azimuth.mddeleted−12
@@ -1,12 +0,0 @@
1−+++
2−title = "Azimuth"
3−weight = 2
4−template = "doc.html"
5−aliases = ["/docs/learn/azimuth"]
6−+++
7−
8−Azimuth is a general-purpose public-key infrastructure (PKI) on the Ethereum blockchain, used as a decentralized ledger for Urbit identities that we call **Urbit identities**. Having an identity is necessary to use the Urbit network, which makes it important to have a neutral ledger to determine who owns what.
9−
10−Azimuth is not, however, part of the Arvo stack. Azimuth is a parallel system that be used as a generalized identity system for other projects. Azimuth "touches" the Urbit ecosystem when an identity is used to boot a virtual computer on the Urbit network for the first time. When that happens, the identity considered **linked** to Azimuth and the identity’s full powers are available for use. Once an identity is linked, it cannot be unlinked.
11−
12−A metaphor might make the relationship between these two systems easier to understand: Azimuth is the bank vault that stores the deed to your house. The Urbit network is the neighborhood that you live in.
concepts/_index.mdnew file+11
@@ -0,0 +1,11 @@
1++++
2+title = "Concepts"
3+weight = 1
4+sort_by = "weight"
5+template = "sections/docs/chapters.html"
6++++
7+
8+The documents in this section are high-level introductions to the Urbit project and components thereof.
9+
10+* [Technical Overview](technical-overview): An in-the-weeds explanation of the components of the Urbit stack.
11+* [Azimuth](azimuth): An overview of Azimuth, the Urbit identity layer.
concepts/azimuth.mdnew file+75
@@ -0,0 +1,75 @@
1++++
2+title = "Azimuth"
3+weight = 4
4+template = "doc.html"
5+aliases = ["/docs/learn/azimuth"]
6++++
7+Azimuth is a general-purpose public-key infrastructure (PKI) on the Ethereum blockchain, used as a platform for Urbit identities that we call _points_. You need a point to use the Arvo network.
8+
9+The primary way to interact with Azimuth is through our [Bridge](https://github.com/urbit/bridge) application and the node libraries that it depends on, [azimuth-js](https://github.com/urbit/azimuth-js) and [urbit-key-generation](https://github.com/urbit/urbit-key-generation). Take a look at the source and play around, or see [Getting Started](/docs/getting-started).
10+
11+## Arvo vs. Azimuth
12+
13+Urbit is a project, not a single computer system. It has multiple components: Arvo, the operating system; and Azimuth, the identity system. Let's compare them.
14+
15+**Arvo** is an operating system that provides the software for a personal server. These personal servers together constitute the peer-to-peer Arvo network. To make this network work on the social level, Arvo is built to work with a system of scarce and immutable identities.
16+
17+**Azimuth** is the public-key infrastructure built to be such a system. A suite of smart-contracts on the Ethereum blockchain, Azimuth determines which Ethereum addresses own which Azimuth identities, called _points_. All point-related operations, such as transfers, are governed at this layer. But Azimuth isn't built strictly for Arvo -- it could be used as a generalized identity system for other projects.
18+
19+These otherwise-parallel systems meet when you want to connect to the Arvo network. Your Arvo personal server, called your _ship_, needs to be able to prove cryptographically that it is who it says it is. This proof comes in the form of a keyfile, derived from your point, that you use to start your ship.
20+
21+A metaphor might help illustrate the relationship between these two systems: the Arvo network is the neighborhood that you live in; Azimuth is the bank vault that stores the deed to your house.
22+
23+## The Urbit HD Wallet
24+
25+Owners of Azimuth points need safeguards that allow for the use of Urbit without jeopardizing cryptographic ownership of their assets. Toward this end, we created the **Urbit Hierarchical Deterministic (HD) Wallet** for the storage of points. The Urbit HD Wallet is not one key-pair, but a system of related key-pairs that each have distinct powers, from setting networking keys for communicating in the Arvo network to transferring ownership of points.
26+
27+The Urbit HD Wallet's derivation paths have a hierarchical structure, so that keys with different powers can be physically separated. A \"master ticket" can re-derive the entire wallet in case of loss. The encryption and authentication keys that points ships use to sign messages within the network are also derived from the wallet.
28+
29+Urbit HD wallets are composed of the following items, which are each assigned to their own individual Ethereum key-pairs.
30+
31+### Master Ticket
32+
33+Think of your master ticket like a very high-value password. The master ticket is the secret code from which all of your other keys are derived. Technically, your master ticket is seed entropy. You should never share it with anyone, and store it very securely. This ticket can derive all of your other keys: your ownership key and all of the related proxies.
34+
35+### Ownership Address
36+
37+An ownership address has all rights over the assets deeded to it. These rights are on-chain actions described and implemented in the Ecliptic, Azimuth's suite of governing smart-contracts.
38+
39+### Proxies
40+
41+Proxy addresses allow you to execute non-ownership related actions like spawning child points, voting, and setting networking keys without jeopardizing the keys you've designated with ownership rights. Setting proxy rights is optional, but it is recommended for on-chain actions you will execute more frequently.
42+
43+- **Management Proxy**
44+
45+ Can configure or set Arvo networking keys and conduct sponsorship related
46+ operations.
47+
48+- **Voting Proxy**
49+
50+ Galaxies only. Galaxies are the part of the galactic senate, and this means
51+ they can cast votes on new proposals including changes to the Ecliptic.
52+
53+- **Spawn Proxy**
54+
55+ For stars and galaxies only. Can create new child points.
56+
57+![](https://media.urbit.org/fora/proposals/UP-8.jpg)
58+
59+
60+Most Ethereum tokens use the ERC-20 standard for smart contracts. Azimuth points
61+are, however, essentially different from most Ethereum tokens, due to points not
62+being fungible. Since any two stars will handle social-networking realities in a
63+different way, they will carry a different reputation. Points are to houses as
64+tokens are to gold.
65+
66+The ERC-721 standard, having been made specifically to provide a smart-contract
67+interface for non-fungible assets, serves our needs well. This is the standard
68+that we use for deeding Azimuth points.
69+
70+Points, and all of their blockchain operations, are governed by the Ecliptic.
71+The Ecliptic is an Ethereum smart-contract that governs point state and the
72+ownership, spawn, management, and voting rights affiliated with your points.
73+
74+For the technical implementation details, take a look at Azimuth's
75+[Github repository](https://github.com/urbit/azimuth).
concepts/technical-overview.mdnew file+169
@@ -0,0 +1,169 @@
1++++
2+title = "Technical overview"
3+weight = 1
4+template = "doc.html"
5++++
6+Urbit is a clean-slate software stack designed to implement an encrypted P2P
7+network of general-purpose personal servers. Each server on this network is a
8+deterministic computer called an 'urbit' that runs on a Unix-based virtual
9+machine.
10+
11+The current Urbit stack includes (among other things):
12+
13+- Arvo: the functional operating system of each urbit, written in Hoon.
14+- Azimuth: the Urbit identity layer, built on the Ethereum blockchain.
15+- Hoon: a strictly typed functional programming language whose standard library
16+ includes a Hoon-to-Nock compiler.
17+- Nock: a low-level combinator language whose formal specification fits readably on a t-shirt.
18+- Vere: a Nock interpreter and Unix-based virtual machine that mediates between
19+ each urbit and the Unix software layer.
20+
21+## Anatomy of a personal server
22+
23+Your urbit is a deterministic computer in the sense that its state is a pure
24+function of its event history. Every event in this history is a
25+[transaction](https://en.wikipedia.org/wiki/Transaction_processing); your
26+urbit's state is effectively an [ACID database](https://en.wikipedia.org/wiki/ACID).
27+
28+Because each urbit is deterministic we can describe its role appropriately in
29+purely functional terms: it maps an input event and the old urbit state to a
30+list of output actions and the subsequent state. This is the Urbit transition
31+function.
32+
33+```
34+<input event, old state> -> <output actions, new state>
35+```
36+
37+For example, one input event could be a keystroke from the terminal, say
38+`[enter]` after having already typed `(add 2 2)`; and an output action could be
39+to print in the terminal window the resulting value of a computation performed
40+when the user hit `[enter]`, in this case `4`. The input event is stored in the
41+urbit's event history.
42+
43+Events always start from outside of your urbit, whether they're local to the
44+computer running the urbit (e.g., a keystroke in the terminal) or they originate
45+elsewhere (e.g., a packet received from another urbit). When an event is
46+processed, various parts of the urbit state can be modified before the resulting
47+list of output actions is returned.
48+
49+Can output actions from your urbit cause side-effects in the outside world?
50+The answer had better be "yes," because a personal server without side effects
51+isn't useful for much. In another sense the answer had better be "no," or else
52+there is a risk of losing functional purity; your urbit cannot _guarantee_ that
53+the side effects in question actually occur. What's the solution?
54+
55+Each urbit is
56+[sandboxed](https://en.wikipedia.org/wiki/Sandbox_%28computer_security%29) in a
57+virtual machine, Vere, which runs on Unix. Code running in your urbit cannot
58+make Unix system calls or otherwise directly affect the underlying platform.
59+Strictly speaking, internal urbit code can only change internal urbit state; it
60+has no way of sending events outside of its runtime environment. Functional
61+purity is preserved.
62+
63+In practical terms, however, you don't want your urbit to be an impotent
64+[brain in a vat](https://en.wikipedia.org/wiki/Brain_in_a_vat). That's why
65+Vere also serves as the intermediary between your urbit and Unix. Vere observes
66+the list of output events, and when external action is called for makes the
67+appropriate system calls itself. When external events relevant to your urbit
68+occur in the Unix layer, Vere encodes and delivers them as input events.
69+
70+### Arvo
71+
72+Arvo is a purely functional, [non-preemptive](https://en.wikipedia.org/wiki/Cooperative_multitasking)
73+OS, written in Hoon, that serves as the event manager of your urbit.
74+It can upgrade itself from over the network without downtime. The Arvo kernel
75+proper is quite simple -- it's only about 600 lines of code, excluding its
76+various modules.
77+
78+The Urbit transition function is implemented in Arvo. Upon being 'poked' by
79+Vere with the pair of `<input event, state>`, Arvo directs the event to the
80+appropriate OS module. The result of each Vere 'poke' is a pair of
81+`<output events, new state>`. Events are typed, and each has an explicit
82+call-stack structure indicating the event's source module in Arvo.
83+
84+Arvo modules are also called 'vanes'. Arvo's vanes are:
85+
86+- Ames: defines and implements Urbit's encrypted P2P network protocol, as well
87+ as Urbit's identity protocol.
88+- Behn: manages timer events for other vanes.
89+- Clay: global, version-controlled, and referentially-transparent file system.
90+- Dill: terminal driver.
91+- Eyre: HTTP web client and server.
92+- Ford: typed functional build system.
93+- Gall: application sandbox and manager.
94+ - Dojo (app): Shell and Hoon REPL.
95+ - Talk (app): Chat client.
96+
97+### Hoon
98+
99+Hoon is a strictly typed functional programming language that compiles itself
100+to Nock and is designed to support higher-order functional programming without
101+requiring knowledge of category theory or other advanced mathematics. Haskell
102+is fun but it isn't for everybody.
103+
104+Hoon aspires to a concrete, imperative feel. To discourage the creation of
105+write-only code, Hoon forbids user-level macros and uses ASCII digraphs instead
106+of keywords. The type system infers only forward and does not use unification,
107+but is not much weaker than Haskell's. The compiler and inference engine is
108+about 3000 lines of Hoon.
109+
110+### Nock
111+
112+Nock is a low-level [homoiconic](https://en.wikipedia.org/wiki/Homoiconicity)
113+combinator language. It's so simple that its [specification](@/docs/learn/nock/definition.md)
114+fits on a t-shirt. In some ways Nock resembles a nano-Lisp but its ambitions
115+are more narrow. Most Lisps are one-layer: a practical language is to be
116+created by extending a theoretically simple interpreter. The abstraction is
117+simple and the implementation is practical. Unfortunately it's far more difficult
118+to enforce both simplicity and practicality in an actual Lisp codebase. Hoon
119+and Nock are two layers: Hoon, the practical layer, compiles itself to Nock, the
120+simple layer. Your urbit runs in Vere, which includes a Nock interpreter, so it
121+can upgrade Hoon over the network without downtime.
122+
123+The Nock data model is quite simple. Every piece of data is a 'noun'. A noun
124+is an atom or a cell. An atom is any unsigned integer. A cell is an ordered
125+pair of nouns. Nouns are acyclic and expose no pointer equality test.
126+
127+### Vere
128+
129+Vere is the Nock runtime environment and Urbit VM. It's written in C, runs on
130+Unix, and is the intermediate layer between your urbit and Unix. As noted
131+earlier, Unix system calls are made by Vere, not Arvo; Vere must also encode
132+and deliver relevant external events to Arvo. Vere is also responsible for
133+implementing jets and maintaining the persistent state of each urbit.
134+
135+In principle, Vere keeps a comprehensive log of every event from the time you
136+initially booted your urbit. What happens if the physical machine loses power
137+and your urbit's state is 'lost' from memory? When your urbit restarts it will
138+replay its entire event history and totally recover its latest state from
139+scratch.
140+
141+In practice, event logs become large and unwieldy over time. Periodically a
142+snapshot of the permanent state is taken and the logs are pruned. You're still
143+able to rebuild your state in case of power outage, down to the last keystroke.
144+
145+Vere is not essential to the Urbit stack; one can imagine using Urbit on a
146+hypervisor, or even bare metal. One member of the community is even working on
147+an independent implementation of Urbit using Graal/Truffle on the JVM.
148+
149+The Urbit stack (compiler, standard library, kernel, modules, and applications,
150+but excluding Vere) is about 30,000 lines of Hoon. Urbit is patent-free and MIT
151+licensed.
152+
153+### Azimuth
154+
155+Azimuth is a general-purpose public-key infrastructure (PKI) on the Ethereum
156+blockchain, used as a decentralized ledger for Urbit identities that we call
157+**points**. Having a point is necessary to use the Urbit network, which makes it
158+important to have a neutral ledger to determine who owns what.
159+
160+Azimuth is not, however, part of the Urbit stack. Azimuth is a parallel system
161+that can be used as a generalized identity system for other projects. Azimuth
162+"touches" the Urbit ecosystem when a point is used to boot a virtual computer
163+on the Urbit network for the first time. When that happens, the point considered
164+**linked** to Azimuth and the point’s full powers are available for use. Once a
165+point is linked, it cannot be unlinked.
166+
167+A metaphor might make the relationship between these two systems to understand:
168+Azimuth is the bank vault that stores the deed to your house. The Urbit network
169+is the neighborhood that you live in.
hoon/_index.mddeleted−24
@@ -1,24 +0,0 @@
1−+++
2−title = "Hoon"
3−weight = 2
4−sort_by = "weight"
5−template = "sections/docs/chapters.html"
6−aliases = ["docs/learn/hoon/"]
7−+++
8−Hoon is a high-level, statically typed, functional programming language, custom-designed for use with Urbit. For a functional language it has a surprisingly imperative style, and mastering it doesn't require knowing any advanced mathematics.
9−
10−Hoon is an unusual language in several respects, both in syntax and semantics. It uses runes (i.e., ASCII digraphs) in place of keywords, and the spacing rules are a bit strict. A great deal can be expressed in few lines, though excessively compressed code tends to be hard to read. Hoon has surprisingly simple semantics, but mastering it requires learning concepts that don't have close analogues in other languages.
11−
12−In this section, you'll find useful resources on the Hoon programming language.
13−
14−## [The Hoon Tutorial](@/docs/hoon/hoon-tutorial/_index.md)
15−
16−This section is the place to learn the fundamentals of the language, from the very beginning.
17−
18−## [The Hoon Workbook](@/docs/hoon/workbook/_index.md)
19−
20−The workbook lets you dive right into code walkthroughs.
21−
22−## [The Style Guide](@/docs/hoon/style.md)
23−
24−This guide shows you how to write code in the correct way.
hoon/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−```
hoon/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−---
hoon/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−---
hoon/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−---
hoon/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−---
hoon/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−---
hoon/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−---
hoon/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−---
hoon/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−---
hoon/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−---
hoon/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−---
hoon/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−---
hoon/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−---
hoon/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−---
hoon/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−---
hoon/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−---
hoon/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−---
hoon/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−---
hoon/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−---
hoon/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−---
hoon/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−---
hoon/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−---
hoon/library/4j.mddeleted−1656
@@ -1,1656 +0,0 @@
1−+++
2−title = "4j: Parsing (Bases and Base Digits)"
3−weight = 37
4−template = "doc.html"
5−aliases = ["/docs/reference/library/4j"]
6−+++
7−### `++ab`
8−
9−Primitive parser engine
10−
11−A core containing numeric parser primitives.
12−
13−#### Source
14−
15−```hoon
16− ++ ab
17− |%
18−```
19−
20−#### Examples
21−
22−```
23− > ab
24− <36.ecc 414.gly 100.xkc 1.ypj %164>
25−```
26−
27−------------------------------------------------------------------------
28−
29−### `++bix:ab`
30−
31−Parse hex pair
32−
33−Parsing `++rule`. Parses a pair of base-16 digits. Used in escapes.
34−
35−#### Accepts
36−
37−XX
38−
39−#### Produces
40−
41−A an atom. XX
42−
43−#### Source
44−
45−```hoon
46− ++ bix (bass 16 (stun [2 2] six))
47−```
48−
49−#### Examples
50−
51−```
52− > (scan "07" bix:ab)
53− q=7
54− > (scan "51" bix:ab)
55− q=81
56− > (scan "a3" bix:ab)
57− q=163
58−```
59−
60−------------------------------------------------------------------------
61−
62−### `++hif:ab`
63−
64−Parse phonetic pair
65−
66−Parsing `++rule`. Parses an atom of odor `@pE`, a phrase of two bytes
67−encoded phonetically.
68−
69−#### Accepts
70−
71−XX
72−
73−#### Produces
74−
75−An atom.
76−
77−#### Source
78−
79−```hoon
80− ++ hif (boss 256 ;~(plug tip tiq (easy ~)))
81−```
82−
83−#### Examples
84−
85−```
86− > (scan "doznec" hif:ab)
87− q=256
88− > (scan "pittyp" hif:ab)
89− q=48.626
90−```
91−
92−------------------------------------------------------------------------
93−
94−### `++huf:ab`
95−
96−Parse two phonetic pairs
97−
98−Parsing `++rule`. Parses and unscrambles an atom of odor @pF, a phrase
99−of two two-byte pairs that are encoded (and scrambled) phonetically.
100−
101−#### Accepts
102−
103−XX
104−
105−#### Produces
106−
107−An atom. XX
108−
109−#### Source
110−
111−```hoon
112− ++ huf %+ cook
113− |=([a/@ b/@] (wred:un ~(zug mu ~(zag mu [a b]))))
114− ;~(plug hif ;~(pfix hep hif))
115−```
116−
117−#### Examples
118−
119−```
120− > (scan "pittyp-pittyp" huf:ab)
121− 328.203.557
122− > (scan "tasfyn-partyv" huf:ab)
123− 65.792
124− > `@ux`(scan "tasfyn-partyv" huf:ab)
125− 0x1.0100
126−```
127−
128−------------------------------------------------------------------------
129−
130−### `++hyf:ab`
131−
132−Parse 8 phonetic bytes
133−
134−Parsing `++rule`. Parses an atom of odor @pG, a phrase of eight of
135−phonetic bytes.
136−
137−#### Accepts
138−
139−An atom of odor `@pG`
140−
141−#### Produces
142−
143−An atom. XX
144−
145−#### Source
146−
147−```hoon
148− ++ hyf (bass 0x1.0000.0000 ;~(plug huf ;~(pfix hep huf) (easy ~)))
149−```
150−
151−#### Examples
152−
153−```
154− > (scan "sondel-forsut-tillyn-nillyt" hyf:ab)
155− q=365.637.097.828.335.095
156− > `@u`~sondel-forsut-tillyn-nillyt
157− 365.637.097.828.335.095
158−```
159−
160−------------------------------------------------------------------------
161−
162−### `++pev:ab`
163−
164−Parse \<= 5 base-32
165−
166−Parsing `++rule`. Parses up to five base-32 digits without a leading zero.
167−
168−#### Accepts
169−
170−Up to five @uv (base 64) digits.
171−
172−#### Produces
173−
174−An atom.
175−
176−#### Source
177−
178−```hoon
179− ++ pev (bass 32 ;~(plug sev (stun [0 4] siv)))
180−```
181−
182−#### Examples
183−
184−```
185− > (scan "a" pev:ab)
186− q=10
187− > (scan "290j" pev:ab)
188− q=74.771
189− > (scan "123456" pev:ab)
190− ! {1 6}
191− ! exit
192− > (scan "090j" pev:ab)
193− ~ <syntax error at [1 11]>
194−```
195−
196−------------------------------------------------------------------------
197−
198−### `++pew:ab`
199−
200−Parse \<= 5 base-64
201−
202−Parsing `++rule`. Parses up to five base-64 digits without a leading zero.
203−
204−#### Accepts
205−
206−Up to five @uw (base 64) digits.
207−
208−#### Produces
209−
210−
211−
212−#### Source
213−
214−```hoon
215− ++ pew (bass 64 ;~(plug sew (stun [0 4] siw)))
216−```
217−
218−#### Examples
219−
220−```
221− > (scan "Q" pew:ab)
222− q=52
223− > (scan "aQ~9" pew:ab)
224− q=2.838.473
225− > `@`0waQ~9
226− 2.838.473
227− > (scan "123456" pew:ab)
228− ! {1 6}
229− ! exit
230− > (scan "012345" pew:ab)
231− ! {1 1}
232− ! exit
233−```
234−
235−------------------------------------------------------------------------
236−
237−### `++piv:ab`
238−
239−Parse 5 base-32
240−
241−Parsing `++rule`. Parses exactly five base-32 digits.
242−
243−#### Accepts
244−
245−#### Produces
246−
247−#### Source
248−
249−```hoon
250− ++ piv (bass 32 (stun [5 5] siv))
251−```
252−
253−#### Examples
254−
255−```
256− > (scan "10b3l" piv:ab)
257− q=1.059.957
258− > (scan "1" piv:ab)
259− ! {1 2}
260− ! exit
261−```
262−
263−------------------------------------------------------------------------
264−
265−### `++piw:ab`
266−
267−Parse 5 base-64
268−
269−Parsing `++rule`. Parses exactly five base-64 digits.
270−
271−#### Accepts
272−
273−#### Produces
274−
275−#### Source
276−
277−```hoon
278− ++ piw (bass 64 (stun [5 5] siw))
279−```
280−
281−#### Examples
282−
283−```
284− > (scan "2C-pZ" piw:ab)
285− q=43.771.517
286− > (scan "2" piv:ab)
287− ! {1 2}
288− ! exit
289−```
290−
291−
292−------------------------------------------------------------------------
293−
294−### `++qeb:ab`
295−
296−Parse \<= 4 binary
297−
298−Parsing `++rule`. Parses a binary number of up to 4 digits in length without
299−a leading zero.
300−
301−#### Accepts
302−
303−#### Produces
304−
305−#### Source
306−
307−```hoon
308− ++ qeb (bass 2 ;~(plug seb (stun [0 3] sib)))
309−```
310−
311−#### Examples
312−
313−```
314− > (scan "1" qeb:ab)
315− q=1
316− > (scan "101" qeb:ab)
317− q=5
318− > (scan "1111" qeb:ab)
319− q=15
320− > (scan "11111" qeb:ab)
321− ! {1 5}
322− ! exit
323− > (scan "01" qeb:ab)
324− ! {1 1}
325− ! exit
326−```
327−
328−------------------------------------------------------------------------
329−
330−### `++qex:ab`
331−
332−Parse \<= 4 hex
333−
334−Parsing `++rule`. Parses a hexadecimal number of up to 4 digits in length
335−without a leading zero.
336−
337−#### Accepts
338−
339−#### Produces
340−
341−#### Source
342−
343−```hoon
344− ++ qex (bass 16 ;~(plug sex (stun [0 3] hit)))
345−```
346−
347−#### Examples
348−
349−```
350− > (scan "ca" qex:ab)
351− q=202
352− > (scan "18ac" qex:ab)
353− q=6.316
354− > (scan "18acc" qex:ab)
355− ! {1 5}
356− ! exit
357− > (scan "08ac" qex:ab)
358− ! {1 1}
359− ! exit
360−```
361−
362−------------------------------------------------------------------------
363−
364−### `++qib:ab`
365−
366−Parse 4 binary
367−
368−Parsing `++rule`. Parses exactly four binary digits.
369−
370−#### Accepts
371−
372−#### Produces
373−
374−#### Source
375−
376−```hoon
377− ++ qib (bass 2 (stun [4 4] sib))
378−```
379−
380−#### Examples
381−
382−```
383− > (scan "0001" qib:ab)
384− q=1
385− > (scan "0100" qib:ab)
386− q=4
387− > (scan "110" qib:ab)
388− ! {1 4}
389− ! exit
390−```
391−
392−------------------------------------------------------------------------
393−
394−### `++qix:ab`
395−
396−Parse 4 hex
397−
398−Parsing `++rule`. Parses exactly four hexadecimal digits.
399−
400−#### Accepts
401−
402−#### Produces
403−
404−#### Source
405−
406−```hoon
407− ++ qix (bass 16 (stun [4 4] six))
408−```
409−
410−#### Examples
411−
412−```
413− > (scan "0100" qix:ab)
414− q=256
415− > (scan "10ff" qix:ab)
416− q=4.351
417− > (scan "0" qix:ab)
418− ! {1 2}
419− ! exit
420−```
421−
422−------------------------------------------------------------------------
423−
424−### `++seb:ab`
425−
426−Parse 1
427−
428−Parsing `++rule`. Parses the number 1.
429−
430−#### Accepts
431−
432−#### Produces
433−
434−#### Source
435−
436−```hoon
437− ++ seb (cold 1 (just '1'))
438−```
439−
440−#### Examples
441−
442−```
443− > (scan "1" seb:ab)
444− 1
445− > (scan "0" seb:ab)
446− ! ~zod/try/~2014.10.23..22.34.21..bfdd/:<[1 1].[1 18]>
447− ! {1 1}
448− > (scan "2" seb:ab)
449− ! ~zod/try/~2014.10.23..22.34.29..d399/:<[1 1].[1 18]>
450− ! {1 1}
451−```
452−
453−------------------------------------------------------------------------
454−
455−### `++sed:ab`
456−
457−Parse decimal
458−
459−Parsing `++rule`. Parses a nonzero decimal digit.
460−
461−#### Accepts
462−
463−#### Produces
464−
465−#### Source
466−
467−```hoon
468− ++ sed (cook |=(a/@ (sub a '0')) (shim '1' '9'))
469−```
470−
471−#### Examples
472−
473−```
474− > (scan "5" sed:ab)
475− 5
476− > (scan "0" sed:ab)
477− ! {1 1}
478− ! exit
479−```
480−
481−------------------------------------------------------------------------
482−
483−### `++sev:ab`
484−
485−Parse base-32
486−
487−Parsing `++rule`. Parses a nonzero base-32 digit
488−
489−#### Accepts
490−
491−#### Produces
492−
493−#### Source
494−
495−```hoon
496− ++ sev ;~(pose sed sov)
497−```
498−
499−#### Examples
500−
501−```
502− > (scan "c" sev:ab)
503− 12
504− ~zod/socialnet=> (scan "0" sev:ab)
505− ! {1 1}
506− ! exit
507−```
508−
509−------------------------------------------------------------------------
510−
511−### `++sew:ab`
512−
513−Parse base-64
514−
515−Parsing `++rule`. Parses a nonzero base-64 digit
516−
517−#### Accepts
518−
519−#### Produces
520−
521−#### Source
522−
523−```hoon
524− ++ sew ;~(pose sed sow)
525−```
526−
527−#### Examples
528−
529−```
530− > (scan "M" sew:ab)
531− 48
532− > (scan "0" sew:ab)
533− ! {1 1}
534− ! exit
535−```
536−
537−------------------------------------------------------------------------
538−
539−### `++sex:ab`
540−
541−Parse hex
542−
543−Parsing `++rule`. Parses a nonzero hexadecimal digit.
544−
545−#### Accepts
546−
547−#### Produces
548−
549−#### Source
550−
551−```hoon
552− ++ sex ;~(pose sed sox)
553−```
554−
555−#### Examples
556−
557−```
558− > (scan "e" sex:ab)
559− 14
560− > (scan "0" sex:ab)
561− ! {1 1}
562− ! exit
563−```
564−
565−------------------------------------------------------------------------
566−
567−### `++sib:ab`
568−
569−Parse binary
570−
571−Parsing `++rule`. Parses a binary digit.
572−
573−#### Accepts
574−
575−#### Produces
576−
577−#### Source
578−
579−```hoon
580− ++ sib (cook |=(a/@ (sub a '0')) (shim '0' '1'))
581−```
582−
583−#### Examples
584−
585−```
586− > (scan "1" sib:ab)
587− 1
588− ~zod/socialnet=> (scan "0" sib:ab)
589− 0
590−```
591−
592−------------------------------------------------------------------------
593−
594−### `++sid:ab`
595−
596−Parse decimal
597−
598−Parsing `++rule`. Parses a decimal digit.
599−
600−#### Accepts
601−
602−#### Produces
603−
604−#### Source
605−
606−```hoon
607− ++ sid (cook |=(a/@ (sub a '0')) (shim '0' '9'))
608−```
609−
610−#### Examples
611−
612−```
613− > (scan "5" sid:ab)
614− 5
615−```
616−
617−------------------------------------------------------------------------
618−
619−### `++siv:ab`
620−
621−Parse base-32
622−
623−Parsing `++rule`. Parses a base-32 digit.
624−
625−#### Accepts
626−
627−#### Produces
628−
629−#### Source
630−
631−```hoon
632− ++ siv ;~(pose sid sov)
633−```
634−
635−#### Examples
636−
637−```
638− > (scan "c" siv:ab)
639− 12
640−```
641−
642−------------------------------------------------------------------------
643−
644−### `++siw:ab`
645−
646−Parse base-64
647−
648−Parsing `++rule`. Parses a base-64 digit.
649−
650−#### Accepts
651−
652−#### Produces
653−
654−#### Source
655−
656−```hoon
657− ++ siw ;~(pose sid sow)
658−```
659−
660−#### Examples
661−
662−```
663− > (scan "M" siw:ab)
664− 48
665−```
666−
667−------------------------------------------------------------------------
668−
669−### `++six:ab`
670−
671−Parse hex
672−
673−Parsing `++rule`. Parses a hexadecimal digit.
674−
675−#### Accepts
676−
677−#### Produces
678−
679−#### Source
680−
681−```hoon
682− ++ six ;~(pose sid sox)
683−```
684−
685−#### Examples
686−
687−```
688− > (scan "e" six:ab)
689− 14
690−```
691−
692−------------------------------------------------------------------------
693−
694−### `++sov:ab`
695−
696−Parse base-32
697−
698−Parsing `++rule`. Parses a base-32 letter.
699−
700−#### Accepts
701−
702−#### Produces
703−
704−#### Source
705−
706−```hoon
707− ++ sov (cook |=(a/@ (sub a 87)) (shim 'a' 'v'))
708−```
709−
710−#### Examples
711−
712−```
713− > (scan "c" sov:ab)
714− 12
715−```
716−------------------------------------------------------------------------
717−
718−### `++sow:ab`
719−
720−Parse base-64
721−
722−Parsing `++rule`. Parses a base-64 letter/symbol.
723−
724−#### Accepts
725−
726−#### Produces
727−
728−#### Source
729−
730−```hoon
731− ++ sow ;~ pose
732− (cook |=(a/@ (sub a 87)) (shim 'a' 'z'))
733− (cook |=(a/@ (sub a 29)) (shim 'A' 'Z'))
734− (cold 62 (just '-'))
735− (cold 63 (just '~'))
736− ==
737−```
738−
739−#### Examples
740−
741−```
742− > (scan "M" sow:ab)
743− 48
744−```
745−
746−------------------------------------------------------------------------
747−
748−### `++sox:ab`
749−
750−Parse hex letter
751−
752−Parsing `++rule`. Parses a hexadecimal letter.
753−
754−#### Accepts
755−
756−#### Produces
757−
758−#### Source
759−
760−```hoon
761− ++ sox (cook |=(a/@ (sub a 87)) (shim 'a' 'f'))
762−```
763−
764−#### Examples
765−
766−```
767− > (scan "e" sox:ab)
768− 14
769−```
770−
771−------------------------------------------------------------------------
772−
773−### `++ted:ab`
774−
775−Parse \<= 3 decimal
776−
777−Parsing `++rule`. Parses a decimal number of up to 3 digits without a
778−leading zero.
779−
780−#### Accepts
781−
782−#### Produces
783−
784−#### Source
785−
786−```hoon
787− ++ ted (bass 10 ;~(plug sed (stun [0 2] sid)))
788−```
789−
790−#### Examples
791−
792−```
793− > (scan "21" ted:ab)
794− q=21
795− > (scan "214" ted:ab)
796− q=214
797− > (scan "2140" ted:ab)
798− {1 4}
799− > (scan "0" ted:ab)
800− ! {1 1}
801− ! exit
802−```
803−
804−------------------------------------------------------------------------
805−
806−### `++tip:ab`
807−
808−Leading phonetic byte
809−
810−Parsing `++rule`. Parses the leading phonetic byte, which represents a
811−syllable.
812−
813−#### Accepts
814−
815−#### Produces
816−
817−#### Source
818−
819−```hoon
820− ++ tip (sear |=(a/@ (ins:po a)) til)
821−```
822−
823−#### Examples
824−
825−```
826− > (scan "doz" tip:ab)
827− 0
828−
829− > (scan "pit" tip:ab)
830− 242
831−```
832−
833−------------------------------------------------------------------------
834−
835−### `++tiq:ab`
836−
837−Trailing phonetic syllable
838−
839−Parsing `++rule`. Parses the trailing phonetic byte, which represents a
840−syllable.
841−
842−#### Accepts
843−
844−#### Produces
845−
846−#### Source
847−
848−```hoon
849− ++ tiq (sear |=(a/@ (ind:po a)) til)
850−
851−```
852−#### Examples
853−
854−```
855− > (scan "zod" tiq:ab)
856− 0
857− > (scan "nec" tiq:ab)
858− 1
859−```
860−
861−------------------------------------------------------------------------
862−
863−### `++tid:ab`
864−
865−Parse 3 decimal digits
866−
867−Parsing `++rule`. Parses exactly three decimal digits.
868−
869−#### Accepts
870−
871−#### Produces
872−
873−#### Source
874−
875−```hoon
876− ++ tid (bass 10 (stun [3 3] sid))
877−```
878−
879−#### Examples
880−
881−```
882− > (scan "013" tid:ab)
883− q=13
884− > (scan "01" tid:ab)
885− ! {1 3}
886− ! exit
887−```
888−
889−------------------------------------------------------------------------
890−
891−### `++til:ab`
892−
893−Parse 3 lowercase
894−
895−Parsing `++rule`. Parses exactly three lowercase letters.
896−
897−#### Accepts
898−
899−#### Produces
900−
901−#### Source
902−
903−```hoon
904− ++ til (boss 256 (stun [3 3] low))
905−```
906−
907−#### Examples
908−
909−```
910− > (scan "mer" til:ab)
911− q=7.497.069
912− > `@t`(scan "mer" til:ab)
913− 'mer'
914− > (scan "me" til:ab)
915− ! {1 3}
916− ! exit
917−```
918−
919−------------------------------------------------------------------------
920−
921−### `++urs:ab`
922−
923−Parse span characters
924−
925−Parsing rule. Parses characters from an atom of the span odor `@ta`.
926−
927−#### Accepts
928−
929−#### Produces
930−
931−#### Source
932−
933−```hoon
934− ++ urs %+ cook
935− |=(a/tape (rap 3 ^-((list @) a)))
936− (star ;~(pose nud low hep dot sig cab))
937−```
938−
939−#### Examples
940−
941−```
942− > `@ta`(scan "asa-lom_tak" urs:ab)
943− ~.asa-lom_tak
944− > `@t`(scan "asa-lom_tak" urs:ab)
945− 'asa-lom_tak'
946−```
947−
948−------------------------------------------------------------------------
949−
950−### `++urt:ab`
951−
952−Parse non-`_` span
953−
954−Parsing rule. Parses all characters of the span odor `@ta` except
955−for cab, `_`.
956−
957−#### Accepts
958−
959−#### Produces
960−
961−#### Source
962−
963−```hoon
964− ++ urt %+ cook
965− |=(a/tape (rap 3 ^-((list @) a)))
966− (star ;~(pose nud low hep dot sig))
967−```
968−
969−#### Examples
970−
971−```
972− > `@t`(scan "asa-lom.t0k" urt:ab)
973− 'asa-lom.t0k'
974−```
975−
976−------------------------------------------------------------------------
977−
978−### `++voy:ab`
979−
980−Parse bas, soq, or bix
981−
982−Parsing rule. Parses an escaped backslash, single quote, or hex pair
983−byte.
984−
985−#### Accepts
986−
987−#### Produces
988−
989−#### Source
990−
991−```hoon
992− ++ voy ;~(pfix bas ;~(pose bas soq bix))
993−```
994−
995−#### Examples
996−
997−```
998− > (scan "\\0a" voy:ab)
999− q=10
1000− > (scan "\\'" voy:ab)
1001− q=39
1002−```
1003−
1004−------------------------------------------------------------------------
1005−
1006−### `++ag`
1007−
1008−Top-level atom parser engine
1009−
1010−A core containing top-level atom parsers.
1011−
1012−#### Accepts
1013−
1014−#### Produces
1015−
1016−#### Source
1017−
1018−```hoon
1019− ++ ag
1020− |%
1021−```
1022−
1023−#### Examples
1024−
1025−```
1026− > ag
1027− <14.vpu 414.mof 100.xkc 1.ypj %164>
1028−```
1029−
1030−------------------------------------------------------------------------
1031−
1032−### `++ape:ag`
1033−
1034−Parse 0 or rule
1035−
1036−Parser modifier. Parses 0 or the sample rule `fel`.
1037−
1038−#### Accepts
1039−
1040−#### Produces
1041−
1042−`fel` is a `rule`.
1043−
1044−#### Source
1045−
1046−```hoon
1047− ++ ape |*(fel/rule ;~(pose (cold 0 (just '0')) fel))
1048−```
1049−
1050−#### Examples
1051−
1052−```
1053− > (scan "202" (star (ape:ag (cold 2 (just '2')))))
1054− ~[2 0 2]
1055−```
1056−
1057−------------------------------------------------------------------------
1058−
1059−### `++bay:ag`
1060−
1061−Parses binary number
1062−
1063−Parsing rule. Parses a binary number without a leading zero.
1064−
1065−#### Accepts
1066−
1067−#### Produces
1068−
1069−#### Source
1070−
1071−```hoon
1072− ++ bay (ape (bass 16 ;~(plug qeb:ab (star ;~(pfix dog qib:ab)))))
1073−```
1074−
1075−#### Examples
1076−
1077−```
1078− > (scan "10.0110" bay:ag)
1079− q=38
1080−```
1081−
1082−------------------------------------------------------------------------
1083−
1084−### `++bip:ag`
1085−
1086−Parse IPv6
1087−
1088−Parsing rule. Parses a `@is`, an IPv6 address.
1089−
1090−#### Accepts
1091−
1092−#### Produces
1093−
1094−#### Source
1095−
1096−```hoon
1097− ++ bip =+ tod=(ape qex:ab)
1098− (bass 0x1.0000 ;~(plug tod (stun [7 7] ;~(pfix dog tod))))
1099−```
1100−
1101−#### Examples
1102−
1103−```
1104− > (scan "0.0.ea.3e6c.0.0.0.0" bip:ag)
1105− q=283.183.420.760.121.105.516.068.864
1106− > `@is`(scan "0.0.ea.3e6c.0.0.0.0" bip:ag)
1107− .0.0.ea.3e6c.0.0.0.0
1108−```
1109−
1110−------------------------------------------------------------------------
1111−
1112−### `++dem:ag`
1113−
1114−Parse decimal with dots
1115−
1116−Parsing rule. Parses a decimal number that includes dot separators.
1117−
1118−#### Accepts
1119−
1120−#### Produces
1121−
1122−#### Source
1123−
1124−```hoon
1125− ++ dem (ape (bass 1.000 ;~(plug ted:ab (star ;~(pfix dog tid:ab)))))
1126−```
1127−
1128−#### Examples
1129−
1130−```
1131− > (scan "52" dem:ag)
1132− q=52
1133− > (scan "13.507" dem:ag)
1134− q=13.507
1135−```
1136−
1137−------------------------------------------------------------------------
1138−
1139−### `++dim:ag`
1140−
1141−Parse decimal number
1142−
1143−Parsing rule. Parses a decimal number without a leading zero.
1144−
1145−#### Accepts
1146−
1147−#### Produces
1148−
1149−#### Source
1150−
1151−```hoon
1152− ++ dim (ape (bass 10 ;~(plug sed:ab (star sid:ab))))
1153−```
1154−
1155−#### Examples
1156−
1157−```
1158− > (scan "52" dim:ag)
1159− q=52
1160− > (scan "013507" dim:ag)
1161− ! {1 2}
1162− ! exit
1163−```
1164−
1165−------------------------------------------------------------------------
1166−
1167−### `++dum:ag`
1168−
1169−Parse decimal with leading `0`
1170−
1171−Parsing rule. Parses a decmial number with leading zeroes.
1172−
1173−#### Accepts
1174−
1175−#### Produces
1176−
1177−#### Source
1178−
1179−```hoon
1180− ++ dum (bass 10 (plus sid:ab))
1181−```
1182−
1183−#### Examples
1184−
1185−```
1186− > (scan "52" dum:ag)
1187− q=52
1188− > (scan "0000052" dum:ag)
1189− q=52
1190− > (scan "13507" dim:ag)
1191− q=13.507
1192−```
1193−
1194−------------------------------------------------------------------------
1195−
1196−### `++fed:ag`
1197−
1198−Parse phonetic base
1199−
1200−Parsing rule. Parses an atom of odor `@p`, the phonetic base.
1201−
1202−#### Accepts
1203−
1204−#### Produces
1205−
1206−#### Source
1207−
1208−```hoon
1209− ++ fed ;~ pose
1210− (bass 0x1.0000.0000.0000.0000 (most doh hyf:ab))
1211− huf:ab
1212− hif:ab
1213− tiq:ab
1214− ==
1215−```
1216−
1217−#### Examples
1218−
1219−```
1220− > (scan "zod" fed:ag)
1221− 0
1222− > (scan "nec" fed:ag)
1223− 1
1224− > (scan "sondel" fed:ag)
1225− 9.636
1226− > ~tillyn-nillyt
1227− ~tillyn-nillyt
1228− > (scan "tillyn-nillyt" fed:ag)
1229− 3.569.565.175
1230− > (scan "tillyn-nillyt-tasfyn-partyv" fed:ag)
1231− 15.331.165.687.565.582.592
1232− > (scan "tillyn-nillyt-tasfyn-partyv--novweb-talrud-talmud-sonfyr" fed:ag)
1233− 282.810.089.790.159.633.869.501.053.313.363.681.181
1234−```
1235−
1236−------------------------------------------------------------------------
1237−
1238−### `++hex:ag`
1239−
1240−Parse hex
1241−
1242−Parsing rule. Parses a hexadecimal number
1243−
1244−#### Accepts
1245−
1246−#### Produces
1247−
1248−#### Source
1249−
1250−```hoon
1251− ++ hex (ape (bass 0x1.0000 ;~(plug qex:ab (star ;~(pfix dog qix:ab)))))
1252−```
1253−
1254−#### Examples
1255−
1256−```
1257− > (scan "4" hex:ag)
1258− q=4
1259− > (scan "1a" hex:ag)
1260− q=26
1261− > (scan "3.ac8d" hex:ag)
1262− q=240.781
1263− > `@ux`(scan "3.ac8d" hex:ag)
1264− 0x3.ac8d
1265−```
1266−
1267−------------------------------------------------------------------------
1268−
1269−### `++lip:ag`
1270−
1271−Parse IPv4 address
1272−
1273−Parsing rule. Parses an IPv4 address.
1274−
1275−#### Accepts
1276−
1277−#### Produces
1278−
1279−#### Source
1280−
1281−```hoon
1282− ++ lip =+ tod=(ape ted:ab)
1283− (bass 256 ;~(plug tod (stun [3 3] ;~(pfix dog tod))))
1284−```
1285−
1286−#### Examples
1287−
1288−```
1289− > (scan "127.0.0.1" lip:ag)
1290− q=2.130.706.433
1291− > `@if`(scan "127.0.0.1" lip:ag)
1292− .127.0.0.1
1293− > `@if`(scan "8.8.8.8" lip:ag)
1294− .8.8.8.8
1295−```
1296−
1297−------------------------------------------------------------------------
1298−
1299−### `++viz:ag`
1300−
1301−Parse Base-32 with dots
1302−
1303−Parsing rule. Parses a Base-32 number with dot separators.
1304−
1305−#### Accepts
1306−
1307−#### Produces
1308−
1309−#### Source
1310−
1311−```hoon
1312− ++ viz (ape (bass 0x200.0000 ;~(plug pev:ab (star ;~(pfix dog piv:ab)))))
1313−```
1314−
1315−#### Examples
1316−
1317−```
1318− > (scan "e2.ol4pm" viz:ag)
1319− q=15.125.353.270
1320−```
1321−
1322−------------------------------------------------------------------------
1323−
1324−### `++vum:ag`
1325−
1326−Parse base-32 string
1327−
1328−Parsing rule. Parses a raw base-32 string.
1329−
1330−#### Accepts
1331−
1332−#### Produces
1333−
1334−#### Source
1335−
1336−```hoon
1337− ++ vum (bass 32 (plus siv:ab))
1338−```
1339−
1340−#### Examples
1341−
1342−```
1343− > (scan "e2ol4pm" vum:ag)
1344− q=15.125.353.270
1345−```
1346−
1347−------------------------------------------------------------------------
1348−
1349−### `++wiz:ag`
1350−
1351−Parse base-64
1352−
1353−Parsing rule. Parses a base-64 number.
1354−
1355−#### Accepts
1356−
1357−#### Produces
1358−
1359−#### Source
1360−
1361−```hoon
1362− ++ wiz (ape (bass 0x4000.0000 ;~(plug pew:ab (star ;~(pfix dog piw:ab)))))
1363− --
1364− ::
1365−```
1366−
1367−#### Examples
1368−
1369−```
1370− > (scan "e2O.l4Xpm" wiz:ag)
1371− q=61.764.130.813.526
1372−```
1373−
1374−---
1375−### `++mu`
1376−
1377−Core used to scramble 16-bit atoms
1378−
1379−A door that contains arms that are used to scramble two atoms, `top`
1380−and `bot`. Used especially in the phonetic base to disguise the
1381−relationship between a destroyer and its cruiser.
1382−
1383−#### Accepts
1384−
1385−#### Produces
1386−
1387−`bot` is an atom.
1388−
1389−`top` is an atom.
1390−
1391−#### Source
1392−
1393−```hoon
1394− ++ mu
1395− |_ [top/@ bot/@]
1396−```
1397−
1398−#### Examples
1399−
1400−```
1401− > ~(. mu 0x20e5 0x5901)
1402− <3.sjm [[@ux @ux] <414.hhh 100.xkc 1.ypj %164>]>
1403−```
1404−
1405−------------------------------------------------------------------------
1406−
1407−### `++zag:mu`
1408−
1409−Add bottom into top
1410−
1411−Produces the cell of `top` and `bot` with `top` scrambled to the result
1412−of adding `bot` to `top` modulo 16. Used to scramble the name of a
1413−destroyer.
1414−
1415−#### Accepts
1416−
1417−#### Produces
1418−
1419−`bot` is an atom.
1420−
1421−`top` is an atom.
1422−
1423−#### Source
1424−
1425−```hoon
1426− ++ zag [p=(end 4 1 (add top bot)) q=bot]
1427−```
1428−
1429−#### Examples
1430−
1431−```
1432− > `[@ux @ux]`~(zag mu 0x20e0 0x201)
1433− [0x22e1 0x201]
1434−```
1435−
1436−------------------------------------------------------------------------
1437−
1438−### `++zig:mu`
1439−
1440−Subtract bottom from top
1441−
1442−The inverse of `++zag`. Produces the cell of `top` and `bot` with
1443−`top` unscrambled. The unscrambled `top` is the sum of the sample `top`
1444−and the 16-bit complement of `bot`. Used to unscramble the name of the
1445−destroyer.
1446−
1447−#### Accepts
1448−
1449−#### Produces
1450−
1451−`bot` is an atom.
1452−
1453−`top` is an atom.
1454−
1455−#### Source
1456−
1457−```hoon
1458− ++ zig [p=(end 4 1 (add top (sub 0x1.0000 bot))) q=bot]
1459−```
1460−
1461−#### Examples
1462−
1463−```
1464− > `[@ux @ux]`~(zig mu 0x2f46 0x1042)
1465− [0x1f04 0x1042]
1466−```
1467−
1468−------------------------------------------------------------------------
1469−
1470−### `++zug:mu`
1471−
1472−Concatenate into atom
1473−
1474−Produces the concatenation of `top` and `bot`. Used to assemble a
1475−destroyer name.
1476−
1477−#### Accepts
1478−
1479−#### Produces
1480−
1481−`bot` is an atom.
1482−
1483−`top` is an atom.
1484−
1485−#### Source
1486−
1487−```hoon
1488− ++ zug (mix (lsh 4 1 top) bot)
1489−```
1490−
1491−#### Examples
1492−
1493−```
1494− > `@ux`~(zug mu 0x10e1 0xfa)
1495− 0x10e1.00fa
1496−```
1497−
1498−
1499−---
1500−### `++ne`
1501−
1502−Digit rendering engine
1503−
1504−A door containing arms that render digits at bases 10, 16, 32, and
1505−64.
1506−
1507−#### Accepts
1508−
1509−#### Produces
1510−
1511−`tig` is an `atom`.
1512−
1513−#### Source
1514−
1515−```hoon
1516− ++ ne
1517− |_ tig/@
1518−```
1519−
1520−#### Examples
1521−
1522−```
1523− > ~(. ne 20)
1524− <4.gut [@ud <414.hhh 100.xkc 1.ypj %164>]>
1525−```
1526−
1527−------------------------------------------------------------------------
1528−
1529−### `++d:ne`
1530−
1531−Render decimal
1532−
1533−Renders a decimal digit as an atom of an ACII byte value.
1534−
1535−#### Accepts
1536−
1537−#### Produces
1538−
1539−`tig` is an `atom`.
1540−
1541−#### Source
1542−
1543−```hoon
1544− ++ d (add tig '0')
1545−```
1546−
1547−#### Examples
1548−
1549−```
1550− > `@t`~(d ne 7)
1551− '7'
1552−
1553−```
1554−
1555−------------------------------------------------------------------------
1556−
1557−### `++x:ne`
1558−
1559−Render hex
1560−
1561−Renders a hexadecimal digit as an atom of an ASCII byte value.
1562−
1563−#### Accepts
1564−
1565−#### Produces
1566−
1567−`tig` is an `atom`.
1568−
1569−#### Source
1570−
1571−```hoon
1572− ++ x ?:((gte tig 10) (add tig 87) d)
1573−```
1574−
1575−#### Examples
1576−
1577−```
1578− > `@t`~(x ne 7)
1579− '7'
1580−
1581− > `@t`~(x ne 14)
1582− 'e'
1583−```
1584−
1585−------------------------------------------------------------------------
1586−
1587−### `++v:ne`
1588−
1589−Render base-32
1590−
1591−Renders a base-32 digit as an atom of an ASCII byte value.
1592−
1593−#### Accepts
1594−
1595−#### Produces
1596−
1597−#### Source
1598−
1599−```hoon
1600− ++ v ?:((gte tig 10) (add tig 87) d)
1601−```
1602−
1603−#### Examples
1604−
1605−```
1606− > `@t`~(v ne 7)
1607− '7'
1608− > `@t`~(v ne 14)
1609− 'e'
1610− > `@t`~(v ne 25)
1611− 'p'
1612−```
1613−
1614−------------------------------------------------------------------------
1615−
1616−### `++w:ne`
1617−
1618−Render base-64
1619−
1620−Renders a base-64 digit as an atom of an ASCII byte value.
1621−
1622−#### Accepts
1623−
1624−#### Produces
1625−
1626−`tig` is an `atom`.
1627−
1628−#### Source
1629−
1630−```hoon
1631− ++ w ?:(=(tig 63) '~' ?:(=(tig 62) '-' ?:((gte tig 36) (add tig 29) x)))
1632− --
1633− ::
1634−```
1635−
1636−#### Examples
1637−
1638−```
1639− > `@t`~(w ne 7)
1640− '7'
1641− > `@t`~(w ne 14)
1642− 'e'
1643− > `@t`~(w ne 25)
1644− 'p'
1645− > `@t`~(w ne 52)
1646− 'Q'
1647− > `@t`~(w ne 61)
1648− 'Z'
1649− > `@t`~(w ne 63)
1650− '~'
1651− > `@t`~(w ne 62)
1652− '-'
1653−```
1654−
1655−
1656−---
hoon/library/4k.mddeleted−276
@@ -1,276 +0,0 @@
1−+++
2−title = "4k: Atom Printing"
3−weight = 38
4−template = "doc.html"
5−aliases = ["/docs/reference/library/4k"]
6−+++
7−### `++co`
8−
9−Literal rendering engine
10−
11−A door that contains arms that operate on the sample coin `lot`.
12−
13−#### Accepts
14−
15−#### Produces
16−
17−`lot` is a `++coin`.
18−
19−#### Source
20−
21−```hoon
22− ++ co !.
23− ~% %co ..co ~
24− =< |_ lot/coin
25−```
26−
27−#### Examples
28−
29−```
30− > < 3.nta
31− { lot/{$many {$~ $ta @t} {$~ $ud @ud} $~}
32− <10.cfg 4.jjn {rep/"" <402.arm 110.jyx 1.ztu $151>}>
33− }
34− >
35−```
36−
37−------------------------------------------------------------------------
38−
39−### `++rear:co`
40−
41−Prepend & render as tape
42−
43−Renders a coin `lot` as a tape prepended to the sample tape `rom`.
44−
45−#### Accepts
46−
47−#### Produces
48−
49−`rom` is a `pe`
50−
51−`lot` is a `++coin`.
52−
53−#### Source
54−
55−```hoon
56− ++ rear |=(rom/tape =>(.(rex rom) rend))
57−```
58−
59−#### Examples
60−
61−```
62− > (~(rear co %$ %ux 200) "--ha")
63− "0xc8--ha"
64−```
65−
66−------------------------------------------------------------------------
67−
68−### `++rent:co`
69−
70−Render as span
71−
72−Renders a coin `lot` as a span.
73−
74−#### Accepts
75−
76−#### Produces
77−
78−`lot` is a `++coin`.
79−
80−#### Source
81−
82−```hoon
83− ++ rent `@ta`(rap 3 rend)
84−```
85−
86−#### Examples
87−
88−```
89− > ~(rent co %$ %ux 200)
90− ~.0xc8
91−
92− > `@t`~(rent co %$ %ux 200)
93− '0xc8'
94−```
95−------------------------------------------------------------------------
96−
97−### `++rend:co`
98−
99−Render as tape
100−
101−Renders a coin `lot` as a tape.
102−
103−#### Accepts
104−
105−#### Produces
106−
107−`lot` is a `++coin`.
108−
109−#### Source
110−
111−```hoon
112− ++ rend
113− ^- tape
114− ?: ?=($blob -.lot)
115− ['~' '0' ((v-co 1) (jam p.lot))]
116− ?: ?=($many -.lot)
117− :- '.'
118− |- ^- tape
119− ?~ p.lot
120− ['_' '_' rep]
121− ['_' (weld (trip (wack rent(lot i.p.lot))) $(p.lot t.p.lot))]
122− =+ [yed=(end 3 1 p.p.lot) hay=(cut 3 [1 1] p.p.lot)]
123− |- ^- tape
124− ?+ yed (z-co q.p.lot)
125− $c ['~' '-' (weld (rip 3 (wood (tuft q.p.lot))) rep)]
126− $d
127− ?+ hay (z-co q.p.lot)
128− $a
129− =+ yod=(yore q.p.lot)
130− => ^+(. .(rep ?~(f.t.yod rep ['.' (s-co f.t.yod)])))
131− => ^+ .
132− %= .
133− rep
134− ?: &(=(~ f.t.yod) =(0 h.t.yod) =(0 m.t.yod) =(0 s.t.yod))
135− rep
136− => .(rep ['.' (y-co s.t.yod)])
137− => .(rep ['.' (y-co m.t.yod)])
138− ['.' '.' (y-co h.t.yod)]
139− ==
140− => .(rep ['.' (a-co d.t.yod)])
141− => .(rep ['.' (a-co m.yod)])
142− => .(rep ?:(a.yod rep ['-' rep]))
143− ['~' (a-co y.yod)]
144− ::
145− $r
146− =+ yug=(yell q.p.lot)
147− => ^+(. .(rep ?~(f.yug rep ['.' (s-co f.yug)])))
148− :- '~'
149− ?: &(=(0 d.yug) =(0 m.yug) =(0 h.yug) =(0 s.yug))
150− ['s' '0' rep]
151− => ^+(. ?:(=(0 s.yug) . .(rep ['.' 's' (a-co s.yug)])))
152− => ^+(. ?:(=(0 m.yug) . .(rep ['.' 'm' (a-co m.yug)])))
153− => ^+(. ?:(=(0 h.yug) . .(rep ['.' 'h' (a-co h.yug)])))
154− => ^+(. ?:(=(0 d.yug) . .(rep ['.' 'd' (a-co d.yug)])))
155− +.rep
156− ==
157− ::
158− $f
159− ?: =(& q.p.lot)
160− ['.' 'y' rep]
161− ?:(=(| q.p.lot) ['.' 'n' rep] (z-co q.p.lot))
162− ::
163− $n ['~' rep]
164− $i
165− ?+ hay (z-co q.p.lot)
166− $f ((ro-co [3 10 4] |=(a/@ ~(d ne a))) q.p.lot)
167− $s ((ro-co [4 16 8] |=(a/@ ~(x ne a))) q.p.lot)
168− ==
169− ::
170− $p
171− =+ dyx=(met 3 q.p.lot)
172− :- '~'
173− ?: (lte dyx 1)
174− (weld (trip (tod:po q.p.lot)) rep)
175− ?: =(2 dyx)
176− ;: weld
177− (trip (tos:po (end 3 1 q.p.lot)))
178− (trip (tod:po (rsh 3 1 q.p.lot)))
179− rep
180− ==
181− =+ [dyz=(met 5 q.p.lot) fin=| dub=&]
182− |- ^- tape
183− ?: =(0 dyz)
184− rep
185− %= $
186− fin &
187− dub !dub
188− dyz (dec dyz)
189− q.p.lot (rsh 5 1 q.p.lot)
190− rep
191− =+ syb=(wren:un (end 5 1 q.p.lot))
192− =+ cog=~(zig mu [(rsh 4 1 syb) (end 4 1 syb)])
193− ;: weld
194− (trip (tos:po (end 3 1 p.cog)))
195− (trip (tod:po (rsh 3 1 p.cog)))
196− `tape`['-' ~]
197− (trip (tos:po (end 3 1 q.cog)))
198− (trip (tod:po (rsh 3 1 q.cog)))
199− `tape`?.(fin ~ ['-' ?.(dub ~ ['-' ~])])
200− rep
201− ==
202− ==
203− ::
204− $r
205− ?+ hay (z-co q.p.lot)
206− $d ['.' '~' (r-co (rlyd q.p.lot))]
207− $h ['.' '~' '~' (r-co (rlyh q.p.lot))]
208− $q ['.' '~' '~' '~' (r-co (rlyq q.p.lot))]
209− $s ['.' (r-co (rlys q.p.lot))]
210− ==
211− ::
212− $u
213− ?: ?=($c hay)
214− %+ welp ['0' 'c' (reap (pad:fa q.p.lot) '1')]
215− (c-co (enc:fa q.p.lot))
216− =- (weld p.gam ?:(=(0 q.p.lot) `tape`['0' ~] q.gam))
217− ^= gam ^- {p/tape q/tape}
218− ?+ hay [~ ((ox-co [10 3] |=(a/@ ~(d ne a))) q.p.lot)]
219− $b [['0' 'b' ~] ((ox-co [2 4] |=(a/@ ~(d ne a))) q.p.lot)]
220− $i [['0' 'i' ~] ((d-co 1) q.p.lot)]
221− $x [['0' 'x' ~] ((ox-co [16 4] |=(a/@ ~(x ne a))) q.p.lot)]
222− $v [['0' 'v' ~] ((ox-co [32 5] |=(a/@ ~(x ne a))) q.p.lot)]
223− $w [['0' 'w' ~] ((ox-co [64 5] |=(a/@ ~(w ne a))) q.p.lot)]
224− ==
225− ::
226− $s
227− %+ weld
228− ?:((syn:si q.p.lot) "--" "-")
229− $(yed 'u', q.p.lot (abs:si q.p.lot))
230− ::
231− $t
232− ?: =('a' hay)
233− ?: =('s' (cut 3 [2 1] p.p.lot))
234− (weld (rip 3 q.p.lot) rep)
235− ['~' '.' (weld (rip 3 q.p.lot) rep)]
236− ['~' '~' (weld (rip 3 (wood q.p.lot)) rep)]
237− ==
238− --
239−```
240−
241−#### Examples
242−
243−```
244− > ~(rend co ~ %ux 200)
245− "0xc8"
246−
247− > ~(rend co %many ~[[%$ ux+200] [%$ p+40]])
248− "._0xc8_~~tem__"
249−
250− > ~(rend co ~ %p 32.819)
251− "~pillyt"
252−
253− > ~(rend co ~ %ux 18)
254− "0x12"
255−
256− > ~(rend co [~ p=[p=%if q=0x7f00.0001]])
257− ".127.0.0.1"
258−
259− > `@ux`.127.0.0.1
260− 2.130.706.433
261−
262− > ~(rend co %many ~[[~ %ud 20] [~ %uw 133] [~ %tas 'sam']])
263− "._20_0w25_sam__"
264−
265− > ~(rend co %blob [1 1])
266− "~0ph"
267−
268− > ~0ph
269− [1 1]
270−
271− > `@uv`(jam [1 1])
272− 0vph
273−```
274−
275−
276−---
hoon/library/4l.mddeleted−608

This diff is too big to show here.

hoon/library/4m.mddeleted−434

This diff is too big to show here.

hoon/library/4n.mddeleted−447

This diff is too big to show here.

hoon/library/4o.mddeleted−782

This diff is too big to show here.

hoon/library/5a.mddeleted−7

This diff is too big to show here.

hoon/library/5b.mddeleted−7

This diff is too big to show here.

hoon/library/5c.mddeleted−7

This diff is too big to show here.

hoon/library/5d.mddeleted−7

This diff is too big to show here.

hoon/library/5e.mddeleted−7

This diff is too big to show here.

hoon/library/5f.mddeleted−176

This diff is too big to show here.

hoon/library/5g.mddeleted−7

This diff is too big to show here.

hoon/library/_index.mddeleted−1733

This diff is too big to show here.

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

This diff is too big to show here.

hoon/library/zuse.mddeleted−10

This diff is too big to show here.

hoon/workbook/_index.mddeleted−17

This diff is too big to show here.

learn/hoon/hoon-tutorial/behn.mdnew file+94

This diff is too big to show here.

reference/_index.mdnew file+33

This diff is too big to show here.

arvo/glossary.md → reference/arvo-glossary.mdrenamed+29−29

This diff is too big to show here.

azimuth/glossary.md → reference/azimuth-glossary.mdrenamed+1−1

This diff is too big to show here.

hoon/cheat-sheet.md → reference/cheat-sheet.mdrenamed+1−1

This diff is too big to show here.

hoon/troubleshooting.md → reference/hoon-errors.mdrenamed+24−24

This diff is too big to show here.

hoon/hoon-expressions/_index.md → reference/hoon-expressions/_index.mdrenamed+5−5

This diff is too big to show here.

hoon/hoon-expressions/advanced.md → reference/hoon-expressions/advanced.mdrenamed+1−1

This diff is too big to show here.

hoon/hoon-expressions/basic.md → reference/hoon-expressions/basic.mdrenamed+1−1

This diff is too big to show here.

hoon/hoon-expressions/irregular.md → reference/hoon-expressions/irregular.mdrenamed+19−20

This diff is too big to show here.

hoon/hoon-expressions/limb/_index.md → reference/hoon-expressions/limb/_index.mdrenamed+2−2

This diff is too big to show here.

hoon/hoon-expressions/limb/limb.md → reference/hoon-expressions/limb/limb.mdrenamed

The content is the same.

hoon/hoon-expressions/limb/wing.md → reference/hoon-expressions/limb/wing.mdrenamed

The content is the same.

hoon/hoon-expressions/rune/_index.md → reference/hoon-expressions/rune/_index.mdrenamed+15−15

This diff is too big to show here.

hoon/hoon-expressions/rune/bar.md → reference/hoon-expressions/rune/bar.mdrenamed+68−68

This diff is too big to show here.

hoon/hoon-expressions/rune/buc.md → reference/hoon-expressions/rune/buc.mdrenamed+9−9

This diff is too big to show here.

hoon/hoon-expressions/rune/cen.md → reference/hoon-expressions/rune/cen.mdrenamed+65−65

This diff is too big to show here.

hoon/hoon-expressions/rune/col.md → reference/hoon-expressions/rune/col.mdrenamed

The content is the same.

hoon/hoon-expressions/rune/constants.md → reference/hoon-expressions/rune/constants.mdrenamed

The content is the same.

hoon/hoon-expressions/rune/dot.md → reference/hoon-expressions/rune/dot.mdrenamed

The content is the same.

hoon/hoon-expressions/rune/ket.md → reference/hoon-expressions/rune/ket.mdrenamed+17−17

This diff is too big to show here.

hoon/hoon-expressions/rune/lus.md → reference/hoon-expressions/rune/lus.mdrenamed

The content is the same.

hoon/hoon-expressions/rune/mic.md → reference/hoon-expressions/rune/mic.mdrenamed+3−3

This diff is too big to show here.

hoon/hoon-expressions/rune/sig.md → reference/hoon-expressions/rune/sig.mdrenamed

The content is the same.

hoon/hoon-expressions/rune/terminators.md → reference/hoon-expressions/rune/terminators.mdrenamed

The content is the same.

hoon/hoon-expressions/rune/tis.md → reference/hoon-expressions/rune/tis.mdrenamed+28−28

This diff is too big to show here.

hoon/hoon-expressions/rune/wut.md → reference/hoon-expressions/rune/wut.mdrenamed+28−28

This diff is too big to show here.

hoon/hoon-expressions/rune/zap.md → reference/hoon-expressions/rune/zap.mdrenamed

The content is the same.

hoon/library/1b.md → reference/library/1b.mdrenamed+1−1

This diff is too big to show here.

hoon/library/1c.md → reference/library/1c.mdrenamed+13−13

This diff is too big to show here.

hoon/library/2c.md → reference/library/2c.mdrenamed+37−37

This diff is too big to show here.

hoon/library/2d.md → reference/library/2d.mdrenamed+6−6

This diff is too big to show here.

hoon/library/2e.md → reference/library/2e.mdrenamed+6−6

This diff is too big to show here.

hoon/library/2f.md → reference/library/2f.mdrenamed+10−10

This diff is too big to show here.

hoon/library/2h.md → reference/library/2h.mdrenamed+19−19

This diff is too big to show here.

hoon/library/2i.md → reference/library/2i.mdrenamed+25−25

This diff is too big to show here.

hoon/library/2o.md → reference/library/2o.mdrenamed+10−10

This diff is too big to show here.

hoon/library/2q.md → reference/library/2q.mdrenamed+13−13

This diff is too big to show here.

hoon/library/3d.md → reference/library/3d.mdrenamed+17−17

This diff is too big to show here.

hoon/library/3f.md → reference/library/3f.mdrenamed+20−20

This diff is too big to show here.

hoon/library/3g.md → reference/library/3g.mdrenamed+17−17

This diff is too big to show here.

hoon/library/4h.md → reference/library/4h.mdrenamed+34−34

This diff is too big to show here.

tutorials/_index.mdnew file+27

This diff is too big to show here.

arvo/_index.md → tutorials/arvo/_index.mdrenamed+9−9

This diff is too big to show here.

arvo/ames.md → tutorials/arvo/ames.mdrenamed

The content is the same.

arvo/behn.md → tutorials/arvo/behn.mdrenamed

The content is the same.

arvo/clay.md → tutorials/arvo/clay.mdrenamed

The content is the same.

arvo/dill.md → tutorials/arvo/dill.mdrenamed

The content is the same.

arvo/eyre.md → tutorials/arvo/eyre.mdrenamed

The content is the same.

arvo/ford.md → tutorials/arvo/ford.mdrenamed+1−1

This diff is too big to show here.

arvo/gall.md → tutorials/arvo/gall.mdrenamed

The content is the same.

azimuth/creating-an-invite-pool.md → tutorials/creating-an-invite-pool.hoonrenamed+1−1

This diff is too big to show here.

hoon/hoon-tutorial/_index.md → tutorials/hoon/_index.mdrenamed+11−4

This diff is too big to show here.

hoon/hoon-tutorial/ackermann.md → tutorials/hoon/ackermann.mdrenamed

The content is the same.

hoon/hoon-tutorial/arms-and-cores.md → tutorials/hoon/arms-and-cores.mdrenamed

The content is the same.

hoon/hoon-tutorial/atoms-auras-and-simple-cell-types.md → tutorials/hoon/atoms-auras-and-simple-cell-types.mdrenamed+1−1

This diff is too big to show here.

hoon/hoon-tutorial/bank-account.md → tutorials/hoon/bank-account.mdrenamed

The content is the same.

hoon/hoon-tutorial/caesar.md → tutorials/hoon/caesar.mdrenamed

The content is the same.

hoon/hoon-tutorial/conditionals.md → tutorials/hoon/conditionals.mdrenamed

The content is the same.

hoon/hoon-tutorial/doors.md → tutorials/hoon/doors.mdrenamed

The content is the same.

hoon/hoon-tutorial/egg-timer.md → tutorials/hoon/egg-timer.mdrenamed+1−1

This diff is too big to show here.

hoon/hoon-tutorial/fibonacci.md → tutorials/hoon/fibonacci.mdrenamed

The content is the same.

hoon/hoon-tutorial/gall.md → tutorials/hoon/gall.mdrenamed+2−2

This diff is too big to show here.

hoon/hoon-tutorial/gates.md → tutorials/hoon/gates.mdrenamed

The content is the same.

hoon/hoon-tutorial/generators.md → tutorials/hoon/generators.mdrenamed

The content is the same.

hoon/hoon-tutorial/hoon-syntax.md → tutorials/hoon/hoon-syntax.mdrenamed+7−7

This diff is too big to show here.

hoon/hoon-tutorial/iron-polymorphism.md → tutorials/hoon/iron-polymorphism.mdrenamed

The content is the same.

hoon/hoon-tutorial/lead-polymorphism.md → tutorials/hoon/lead-polymorphism.mdrenamed

The content is the same.

hoon/hoon-tutorial/libraries.md → tutorials/hoon/libraries.mdrenamed

The content is the same.

hoon/hoon-tutorial/list-of-numbers.md → tutorials/hoon/list-of-numbers.mdrenamed+1−1

This diff is too big to show here.

hoon/hoon-tutorial/lists.md → tutorials/hoon/lists.mdrenamed

The content is the same.

hoon/hoon-tutorial/molds.md → tutorials/hoon/molds.mdrenamed

The content is the same.

hoon/hoon-tutorial/nouns.md → tutorials/hoon/nouns.mdrenamed

The content is the same.

hoon/hoon-tutorial/recursion.md → tutorials/hoon/recursion.mdrenamed+1−1

This diff is too big to show here.

hoon/hoon-tutorial/setup.md → tutorials/hoon/setup.mdrenamed+1−1

This diff is too big to show here.

hoon/hoon-tutorial/structures-and-complex-types.md → tutorials/hoon/structures-and-complex-types.mdrenamed+1−1

This diff is too big to show here.

hoon/style.md → tutorials/hoon/style.mdrenamed+2−2

This diff is too big to show here.

hoon/hoon-tutorial/the-subject-and-its-legs.md → tutorials/hoon/the-subject-and-its-legs.mdrenamed

The content is the same.

hoon/hoon-tutorial/trees-sets-and-maps.md → tutorials/hoon/trees-sets-and-maps.mdrenamed

The content is the same.

hoon/hoon-tutorial/type-checking-and-type-inference.md → tutorials/hoon/type-checking-and-type-inference.mdrenamed

The content is the same.

hoon/hoon-tutorial/type-polymorphism.md → tutorials/hoon/type-polymorphism.mdrenamed−2

This diff is too big to show here.

tutorials/hoon/workbook/_index.mdnew file+17

This diff is too big to show here.

hoon/workbook/bomb.md → tutorials/hoon/workbook/bomb.mdrenamed

The content is the same.

hoon/workbook/digits.md → tutorials/hoon/workbook/digits.mdrenamed+1−1

This diff is too big to show here.

hoon/workbook/eightball.md → tutorials/hoon/workbook/eightball.mdrenamed+1−1

This diff is too big to show here.

hoon/workbook/traffic-light.md → tutorials/hoon/workbook/traffic-light.mdrenamed+2−2

This diff is too big to show here.

nock/_index.md → tutorials/nock/_index.mdrenamed+4−4

This diff is too big to show here.

nock/definition.md → tutorials/nock/definition.mdrenamed

The content is the same.

nock/example.md → tutorials/nock/example.mdrenamed

The content is the same.

nock/explanation.md → tutorials/nock/explanation.mdrenamed

The content is the same.

nock/implementations.md → tutorials/nock/implementations.mdrenamed+1−1

This diff is too big to show here.

arvo/sail-and-udon.md → tutorials/sail-and-udon.mdrenamed

The content is the same.

arvo/ship-troubleshooting.md → tutorials/ship-troubleshooting.mdrenamed

The content is the same.

vere/_index.md → tutorials/vere/_index.mdrenamed+5−5

This diff is too big to show here.

vere/api.md → tutorials/vere/api.mdrenamed

The content is the same.

vere/c.md → tutorials/vere/c.mdrenamed

The content is the same.

vere/jetting.md → tutorials/vere/jetting.mdrenamed+2−2

This diff is too big to show here.

vere/nouns.md → tutorials/vere/nouns.mdrenamed

The content is the same.

vere/runtime.md → tutorials/vere/runtime.mdrenamed

The content is the same.