on c19bc7a help sign in
858 lines 13 kB history raw
1:- :~ navhome/'/docs/'
2 sort/'9'
3 title/'2f: Noun Ordering'
4 ==
6;>
9# 2f: noun ordering
11### `++aor`
13Alphabetical order
15Computes whether `a` and `b` are in alphabetical order, producing a flag.
17#### Accepts
19`a` is a noun.
21`b` is a noun.
23#### Produces
25A flag.
27#### Source
29```
30 ++ aor
31 ~/ %aor
32 |= [a=* b=*]
33 ^- ?
34 ?: =(a b) &
35 ?. ?=(@ a)
36 ?: ?=(@ b) |
37 ?: =(-.a -.b)
38 $(a +.a, b +.b)
39 $(a -.a, b -.b)
40 ?. ?=(@ b) &
41 |-
42 =+ [c=(end 3 1 a) d=(end 3 1 b)]
43 ?: =(c d)
44 $(a (rsh 3 1 a), b (rsh 3 1 b))
45 (lth c d)
46```
48#### Examples
50```
51 > (aor 'a' 'b')
52 %.y
54 > (aor 'b' 'a')
55 %.n
57 > (aor 'a' 'a')
58 %.y
60 > (aor "foo" "bar")
61 %.n
63 > (aor "bar" "foo")
64 %.y
66 > (aor "abcdefz" "abcdefa")
67 %.n
69 > (aor "abcdefa" "abcdefz")
70 %.y
72 > (aor 10.000 17.000)
73 %.y
75 > (aor 10 9)
76 %.n
77```
80---
81### `++dor`
83Numeric order
85Computes whether `a` and `b` are in ascending numeric order, producing a flag.
87#### Accepts
89`a` is a noun.
91`b` is a noun.
93#### Produces
95A flag.
97#### Source
99```
100 ++ dor
101 ~/ %dor
102 |= [a=* b=*]
103 ^- ?
104 ?: =(a b) &
105 ?. ?=(@ a)
106 ?: ?=(@ b) |
107 ?: =(-.a -.b)
108 $(a +.a, b +.b)
109 $(a -.a, b -.b)
110 ?. ?=(@ b) &
111 (lth a b)
112```
114#### Examples
116```
117 > (dor 1 2)
118 %.y
120 > (dor 2 1)
121 %.n
123 > (dor ~[1 2 3] ~[1 2 4])
124 %.y
126 > (dor ~[1 2 4] ~[1 2 3])
127 %.n
129 > (dor `(list @)`~[99 100 10.000] ~[99 101 10.000])
130 %.y
132 > (dor ~[99 101 10.999] `(list @)`~[99 100 10.000])
133 %.n
134```
136#### Discussion
138If `a` and `b` are both atoms, `dor` is equivalent to [`lte`](../1a). If they're
139cells, `dor` recurses on the heads, and then if the heads are the same it checks
140the tails.
142If one sample is a cell and the other is an atom, the cell sample is treated as
143"greater."
146---
147### `++gor`
149Hash order
151Computes whether of `(mug a)` and `(mug b)` are in ascending numeric order,
152producing a flag. If the `mug` hashes are equal, `a` and `b` are compared by
153`dor` instead.
155[`mug`](../2e) is the the 31-bit nonzero FNV-1a hash algorithm.
157#### Accepts
159`a` is a noun.
161`b` is a noun.
163#### Produces
165A flag.
167#### Source
169```
170 ++ gor
171 ~/ %gor
172 |= [a=* b=*]
173 ^- ?
174 =+ [c=(mug a) d=(mug b)]
175 ?: =(c d)
176 (dor a b)
177 (lth c d)
178```
180#### Examples
182```
183 > (gor 'd' 'c')
184 %.y
186 > 'd'
187 'd'
189 > 'c'
190 'c'
192 > `@ud`'d'
193 100
195 > `@ud`'c'
196 99
198 > (mug 'd')
199 1.628.185.714
201 > (mug 'c')
202 1.712.073.811
204 > (gor 'd' 'c')
205 %.y
207 > (gor 'c' 'd')
208 %.n
210 > (gor "foo" "bar")
211 %.n
213 > (gor (some 10) `(list @)`[1 2 3 ~])
214 %.n
215```
217#### Discussion
219`map`s use `gor` on the key for horizontal ordering and `vor` for
220vertical order. `map`s only look at the keys (the head of the key-value pair
221elements) for ordering.
223---
224### `++hor`
226Horizontal hash order
228If `a` and `b` are atoms, they are computed as samples of `gor`, producing a
229flag.
231If `a` and `b` are cells, `hor` checks to see if their heads are equal. If their
232heads are equal, `gor` is computed on their tails, producing a flag. If their
233heads are not equal, `gor` is computed on their heads, producing a flag.
235If `a` is an atom and `b` is not, then `%.y` is produced. If `b` is an atom and
236`a` is not, `%.n` is produced.
238#### Accepts
240`a` is a noun.
242`b` is a noun.
244#### Produces
246A flag.
248#### Source
250```
251 ++ hor
252 ~/ %hor
253 |= [a=* b=*]
254 ^- ?
255 ?: ?=(@ a)
256 ?. ?=(@ b) &
257 (gor a b)
258 ?: ?=(@ b) |
259 ?: =(-.a -.b)
260 (gor +.a +.b)
261 (gor -.a -.b)
262```
264#### Examples
266```
267 > (hor . 1)
268 %.n
270 > (hor 1 2)
271 %.y
273 > (hor "abc" "cba")
274 %.y
276 > (hor 'c' 'd')
277 %.n
279 > (hor 100 [1 1])
280 %.y
282 > (hor [1 1] 100)
283 %.n
285 > (hor 500.000.000 "foo")
286 %.y
288 > (hor "foo" 500.000.000)
289 %.n
291 > (hor 0 "foo")
292 %.y
294 > (gor `(list @)`[0 ~] 1)
295 %.n
297 > (hor `(list @)`[50 500 5.000 ~] 1)
298 %.n
299```
301#### Discussion
303Sets (+set, +in) use `hor` for their horizontal order and `vor` for their
304vertical order. See [`apt:in`](../2h) to see how a set verifies its correctness.
305`vor` is used to verify.
307---
308### `++lor`
310Leg order
312Computes whether the corresponding legs of `a` and `b` are in ascending
313numeric order, producing a flag.
315#### Accepts
317`a` is a noun.
319`b` is a noun.
321#### Accepts
323A flag.
325#### Source
327```
328 ++ lor
329 ~/ %lor
330 |= [a=* b=*]
331 ^- ?
332 ?: =(a b) &
333 ?@ a
334 ?^ b &
335 (lth a b)
336 ?: =(-.a -.b)
337 $(a +.a, b +.b)
338 $(a -.a, b -.b)
339```
341#### Examples
343```
344 > (lor 1 2)
345 %.y
347 > (lor 2 1)
348 %.n
350 > (lor 9 [1 2])
351 %.y
353 > (lor `(list @)`[1 2 3 ~] `(list @)`[1 2 3 4 ~])
354 %.y
356 > (lor `(list @)`[1 2 3 ~] `(list @)`[1 2 2 ~])
357 %.n
359 > (lor `(list @)`[1 2 3 ~] `(list @)`[2 2 ~])
360 %.y
362 > (lor [2 2 5] [1 5 9 8])
363 %.n
365 > (lor [1 5 8] [1 5 9 8])
366 %.y
368 > (lor [1 2 3] [1 2])
369 !! exit
370```
372#### Discussion
374`lor` is no longer used internally.
376---
377### `++vor`
379Vertical order
381Computes whether the double-hashes `(mug (mug a))` and `(mug (mug b))` are in
382ascending numeric order, producing a flag. If the double-`mug` hashes are
383equal, `a` and `b` are compared by `dor` instead.
385[`mug`](../2e) is the the 31-bit nonzero FNV-1a hash algorithm.
388#### Accepts
390`a` is a noun
392`b` is a noun
394#### Produces
396A flag.
398#### Source
400```
401 ++ vor
402 ~/ %vor
403 |= [a=* b=*]
404 ^- ?
405 =+ [c=(mug (mug a)) d=(mug (mug b))]
406 ?: =(c d)
407 (dor a b)
408 (lth c d)
409```
411#### Examples
413```
414 > (vor 'f' 'g')
415 %.y
417 > [(mug 'f') (mug 'g')]
418 [1.661.740.952 1.644.963.335]
420 > [(mug (mug 'f')) (mug (mug 'g'))]
421 [261.421.509 1.861.258.547]
423 > (vor 'a' 'z')
424 %.n
426 > (vor 43.326 41.106)
427 %.n
428```
430#### Discussion
432Maps, sets, and queues all use `vor` to check for vertical ordering. Maps and
433sets also use `gor` and `hor` for horizontal order, respectively, but queues use
434vertical ordering alone.
436Since hashing removes correlation, double-`mug`ging with `vor` removes
437correlation with single-`mug`ged `hor`. Vertical order becomes uncorrelated
438with horizontal order.
441---
443### `++noun`
445```
446 ++ noun ,* :: any noun
447```
449Used nowhere XX
451```
452 > `noun`~[1 2 3]
453 [1 2 3 0]
454```
457---
459### `++null`
461```
462 ++ null ,~ :: null, nil, etc
463```
465Used nowhere XX
467```
468 > :type; *null
469 ~
470 %~
471```
474---
476### `++port`
478XX move to `++ut`
480Type and location of core-shaped thing? XX Compiler Internals
482#### Source
484```
485 ++ port $: p=axis ::
486 $= q ::
487 $% [%& p=type] ::
488 [%| p=axis q=(list ,[p=type q=foot])] ::
489 == ::
490 == ::
491```
493#### Examples
495```
496 > *port
497 [p=0 q=[%.y p=%void]]
498```
501---
503### `++span`
505ASCII atom
507A restricted text atom for canonical atom syntaxes. The prefix is `~.`.
508There are no escape sequences except `~~`, which means `~`, and `~-`,
509which means `_`. `-` and `.` encode themselves. No other characters
510besides numbers and lowercase letters are permitted.
512#### Source
514```
515 ++ span ,@ta :: text-atom (ASCII)
516```
519#### Examples
521```
522 > *span
523 ~.
525 > `@t`~.foo
526 'foo'
527 > `@t`~.foo.bar
528 'foo.bar'
529 > `@t`~.foo~~bar
530 'foo~bar'
531 > `@t`~.foo~-bar
532 'foo_bar'
533 > `@t`~.foo-bar
534 'foo-bar'
535```
538---
540### `++tiki`
542XX move to `++ut`
544#### Source
546```
547 ++ tiki :: test case
548```
550#### Examples
552```
553A `++wing` or `++hoon`.
555 > (ream '=+ a=4 ?-(a @ ~)')
556 [ %tsls
557 p=[%ktts p=p=%a q=[%dtzy p=%ud q=4]]
558 q
559 [ %wthz
560 p=[%.y p=~ q=~[%a]]
561 q=~[[p=[%axil p=[%atom p=~.]] q=[%bczp p=%null]]]
562 ]
563 ]
564 > (ream '=+ a=4 ?-(4 @ ~)')
565 [ %tsls
566 p=[%ktts p=p=%a q=[%dtzy p=%ud q=4]]
567 q
568 [ %wthz
569 p=[%.n p=~ q=[%dtzy p=%ud q=4]]
570 q=~[[p=[%axil p=[%atom p=~.]] q=[%bczp p=%null]]]
571 ]
572 ]
573```
576---
578### `++toga`
580Tree of faces
582A face, or tree of faces. A `++toga` is applied to anything assigned
583using `^=`.
585XX move to `++ut` and rune doc (for \^= examples)
587#### Source
589```
590 ++ toga :: face control
591 [2 p=toga q=toga] :: cell toga
592 == ::
593```
595#### Examples
597```
598 > a=1
599 a=1
600 > (ream 'a=1')
601 [%ktts p=p=%a q=[%dtzy p=%ud q=1]]
602 > [a b]=[1 2 3]
603 [a=1 b=[2 3]]
604 > (ream '[a b]=[1 2 3]')
605 [ %ktts
606 p=[%2 p=p=%a q=p=%b]
607 q=[%cltr p=~[[%dtzy p=%ud q=1] [%dtzy p=%ud q=2] [%dtzy p=%ud q=3]]]
608 ]
610 > [a ~]=[1 2 3]
611 [a=1 2 3]
612 > (ream '[a ~]=[1 2 3]')
613 [ %ktts
614 p=[%2 p=p=%a q=[%0 ~]]
615 q=[%cltr p=~[[%dtzy p=%ud q=1] [%dtzy p=%ud q=2] [%dtzy p=%ud q=3]]]
616 ]
617```
620---
622### `++tone`
624Intermediate Nock computation result
626Similar to `++toon`, but stack trace is not yet rendered.
628#### Source
630```
631 ++ tone $% [%0 p=*] :: success
632```
634#### Examples
636```
637 > (mink [[20 21] 0 3] ,~)
638 [%0 p=21]
640 > (mink [[0] !=(.^(cy//=main/1))] ,~)
641 [%1 p=~[[31.075 1.685.027.454 1.852.399.981 49 0]]]
642 > (path [31.075 1.685.027.454 1.852.399.981 49 0])
643 /cy/~zod/main/1
645 > (mink [[1 2] !=(~|(%hi +(.)))] ,~)
646 [%2 p=~[[~.yelp 26.984]]]
647 > (mink [[1 2] !=(!:(+(.)))] ,~)
648 [ %2
649 p
650 ~[
651 [ ~.spot
652 [ [ 1.685.027.454
653 7.959.156
654 \/159.445.990.350.374.058.574.398.238.344.143.957.205.628.479.572.65\/
655 8.112.403.878.526
656 \/ \/
657 0
658 ]
659 [1 20]
660 1
661 24
662 ]
663 ]
664 ]
665 ]
666```
669---
671### `++tuna`
673XML template tree
675An XML template tree.
677#### Source
679```
680 ++ tuna :: tagflow
681 [%d p=hoon] :: dynamic list
682 [%e p=hoon q=(list tuna)] :: element
683 [%f p=(list tuna)] :: subflow
684 == ::
685```
687#### Examples
689Leaf %a contains plain-text, %b an empty tag, %c a static list, %d a
690dynamic list, %e a full node element containing a hoon and a list of
691tuna, and %f is a empty node.
693See also: `++sail`
697---
699### `++tusk`
701List of expressions
703List of `++hoon`s. In `:*`, for example, your contents is
704a `++tusk`.
706#### Source
708```
709 ++ tusk (list hoon) ::
710```
712#### Examples
714```
715 > (ream '[1 2 3]')
716 [%cltr p=~[[%dtzy p=%ud q=1] [%dtzy p=%ud q=2] [%dtzy p=%ud q=3]]]
717 > (tusk +:(ream '[1 2 3]'))
718 ~[[%dtzy p=%ud q=1] [%dtzy p=%ud q=2] [%dtzy p=%ud q=3]]
719```
722---
724### `++hoon`
726Expression
728An expression, or AST.
730See Rune section of Hoon reference
734---
736### `++tyke`
738List of 'maybe' hoons
740List of `++unit` `++hoon`, or gaps left to be inferred, in `++path`
741parsing. When you use a path such as `/=main=/pub/src/doc` the path is in fact
742a `++tyke`, where the `=` are inferred from your current path.
745#### Source
747```
748 ++ tyke (list (unit hoon)) ::
749```
751#### Examples
753```
754 > (scan "/==as=" porc:vast)
755 [0 ~[~ ~ [~ [%dtzy p=%tas q=29.537]] ~]]
756 > `tyke`+:(scan "/==as=" porc:vast)
757 ~[~ ~ [~ [%dtzy p=%tas q=29.537]] ~]
758```
761---
763### `++typo`
765Pointer for `++type`
767Pointer for `++type`. `++typo` preserves the previous `++type` in your
768context when upating.
770#### Source
772```
773 ++ typo type :: old type
774```
776#### Examples
778See also: `++seem`, `++vise`, `++type`
782---
784### `++tyre`
786List, term hoon
788Associative list of `++term` `++hoon`, used in jet hint processing.
790#### Source
792```
793 ++ tyre (list ,[p=term q=hoon]) ::
794```
797---
799### `++vase`
801Typed data. A `++vase` is used wherever typed data is explicitly worked
802with.
804#### Source
806```
807 ++ vase ,[p=type q=*] :: type-value pair
808```
810#### Examples
812```
813 > `vase`!>(~)
814 [p=[%cube p=0 q=[%atom p=%n]] q=0]
815```
818---
820### `++vise`
822Convert during reboot
824Used to convert from previously-typed data during reboot.
826#### Source
828```
829 ++ vise ,[p=typo q=*] :: old vase
830```
832#### Examples
834See also: `++typo`, `++seer`
838---
840### `++wing`
842```
843 ++ wing (list limb) ::
844```
846Address in subject. A `++wing` is a path to a value in the subject. A
847term alone is the trivial case of a `++wing`.
849See also: `++hoon`
851```
852 > (ream 'a.+.c')
853 [%cnzz p=~[%a [%.y p=3] %c]]
854 > (wing +:(ream 'a.+.c'))
855 ~[%a [%.y p=3] %c]
856```
858---