Urbit / Docs

2f: noun ordering

++aor

Alphabetical order

Computes whether a and b are in alphabetical order, producing a flag.

Accepts

a is a noun.

b is a noun.

Produces

A flag.

Source

    ++  aor
      ~/  %aor
      |=  [a=* b=*]
      ^-  ?
      ?:  =(a b)  &
      ?.  ?=(@ a)
        ?:  ?=(@ b)  |
        ?:  =(-.a -.b)
          $(a +.a, b +.b)
        $(a -.a, b -.b)
      ?.  ?=(@ b)  &
      |-
      =+  [c=(end 3 1 a) d=(end 3 1 b)]
      ?:  =(c d)
        $(a (rsh 3 1 a), b (rsh 3 1 b))
      (lth c d)

Examples

    > (aor 'a' 'b')
    %.y

    > (aor 'b' 'a')
    %.n

    > (aor 'a' 'a')
    %.y

    > (aor "foo" "bar")
    %.n

    > (aor "bar" "foo")
    %.y

    > (aor "abcdefz" "abcdefa")
    %.n

    > (aor "abcdefa" "abcdefz")
    %.y

    > (aor 10.000 17.000)
    %.y

    > (aor 10 9)
    %.n

++dor

Numeric order

Computes whether a and b are in ascending numeric order, producing a flag.

Accepts

a is a noun.

b is a noun.

Produces

A flag.

Source

    ++  dor
      ~/  %dor
      |=  [a=* b=*]
      ^-  ?
      ?:  =(a b)  &
      ?.  ?=(@ a)
        ?:  ?=(@ b)  |
        ?:  =(-.a -.b)
          $(a +.a, b +.b)
        $(a -.a, b -.b)
      ?.  ?=(@ b)  &
      (lth a b)

Examples

    > (dor 1 2)
    %.y

    > (dor 2 1)
    %.n

    > (dor ~[1 2 3] ~[1 2 4])
    %.y

    > (dor ~[1 2 4] ~[1 2 3])
    %.n

    > (dor `(list @)`~[99 100 10.000] ~[99 101 10.000])
    %.y

    > (dor ~[99 101 10.999] `(list @)`~[99 100 10.000])
    %.n

Discussion

If a and b are both atoms, dor is equivalent to lte. If they're cells, dor recurses on the heads, and then if the heads are the same it checks the tails.

If one sample is a cell and the other is an atom, the cell sample is treated as “greater.”


++gor

Hash order

Computes whether of (mug a) and (mug b) are in ascending numeric order, producing a flag. If the mug hashes are equal, a and b are compared by dor instead.

mug is the the 31-bit nonzero FNV-1a hash algorithm.

Accepts

a is a noun.

b is a noun.

Produces

A flag.

Source

    ++  gor
      ~/  %gor
      |=  [a=* b=*]
      ^-  ?
      =+  [c=(mug a) d=(mug b)]
      ?:  =(c d)
        (dor a b)
      (lth c d)

Examples

    > (gor 'd' 'c')
    %.y

    > 'd'
    'd'

    > 'c'
    'c'

    > `@ud`'d'
    100

    > `@ud`'c'
    99

    > (mug 'd')
    1.628.185.714

    > (mug 'c')
    1.712.073.811

    > (gor 'd' 'c')
    %.y

    > (gor 'c' 'd')
    %.n

    > (gor "foo" "bar")
    %.n

    > (gor (some 10) `(list @)`[1 2 3 ~])
    %.n

Discussion

maps use gor on the key for horizontal ordering and vor for vertical order. maps only look at the keys (the head of the key-value pair elements) for ordering.


++hor

Horizontal hash order

If a and b are atoms, they are computed as samples of gor, producing a flag.

If a and b are cells, hor checks to see if their heads are equal. If their heads are equal, gor is computed on their tails, producing a flag. If their heads are not equal, gor is computed on their heads, producing a flag.

If a is an atom and b is not, then %.y is produced. If b is an atom and a is not, %.n is produced.

Accepts

a is a noun.

b is a noun.

Produces

A flag.

Source

    ++  hor
      ~/  %hor
      |=  [a=* b=*]
      ^-  ?
      ?:  ?=(@ a)
        ?.  ?=(@ b)  &
        (gor a b)
      ?:  ?=(@ b)  |
      ?:  =(-.a -.b)
        (gor +.a +.b)
      (gor -.a -.b)

Examples

    > (hor . 1)
    %.n

    > (hor 1 2)
    %.y

    > (hor "abc" "cba")
    %.y

    > (hor 'c' 'd')
    %.n

    > (hor 100 [1 1])
    %.y

    > (hor [1 1] 100)
    %.n

    > (hor 500.000.000 "foo")
    %.y

    > (hor "foo" 500.000.000)
    %.n

    > (hor 0 "foo")
    %.y

    > (gor `(list @)`[0 ~] 1)
    %.n

    > (hor `(list @)`[50 500 5.000 ~] 1)
    %.n

Discussion

Sets (+set, +in) use hor for their horizontal order and vor for their vertical order. See apt:in to see how a set verifies its correctness. vor is used to verify.


++lor

Leg order

Computes whether the corresponding legs of a and b are in ascending numeric order, producing a flag.

Accepts

a is a noun.

b is a noun.

Accepts

A flag.

Source

    ++  lor
      ~/  %lor
      |=  [a=* b=*]
      ^-  ?
      ?:  =(a b)  &
      [email protected]  a
        ?^  b  &
        (lth a b)
      ?:  =(-.a -.b)
        $(a +.a, b +.b)
      $(a -.a, b -.b)

Examples

    > (lor 1 2)
    %.y

    > (lor 2 1)
    %.n

    > (lor 9 [1 2])
    %.y

    > (lor `(list @)`[1 2 3 ~] `(list @)`[1 2 3 4 ~])
    %.y

    > (lor `(list @)`[1 2 3 ~] `(list @)`[1 2 2 ~])
    %.n

    > (lor `(list @)`[1 2 3 ~] `(list @)`[2 2 ~])
    %.y

    > (lor [2 2 5] [1 5 9 8])
    %.n

    > (lor [1 5 8] [1 5 9 8])
    %.y

    > (lor [1 2 3] [1 2])
    !! exit

Discussion

lor is no longer used internally.


++vor

Vertical order

Computes whether the double-hashes (mug (mug a)) and (mug (mug b)) are in ascending numeric order, producing a flag. If the double-mug hashes are equal, a and b are compared by dor instead.

mug is the the 31-bit nonzero FNV-1a hash algorithm.

Accepts

a is a noun

b is a noun

Produces

A flag.

Source

    ++  vor
      ~/  %vor
      |=  [a=* b=*]
      ^-  ?
      =+  [c=(mug (mug a)) d=(mug (mug b))]
      ?:  =(c d)
        (dor a b)
      (lth c d)

Examples

    > (vor 'f' 'g')
    %.y

    > [(mug 'f') (mug 'g')]
    [1.661.740.952 1.644.963.335]

    > [(mug (mug 'f')) (mug (mug 'g'))]
    [261.421.509 1.861.258.547]

    > (vor 'a' 'z')
    %.n

    > (vor 43.326 41.106)
    %.n

Discussion

Maps, sets, and queues all use vor to check for vertical ordering. Maps and sets also use gor and hor for horizontal order, respectively, but queues use vertical ordering alone.

Since hashing removes correlation, double-mugging with vor removes correlation with single-mugged hor. Vertical order becomes uncorrelated with horizontal order.


++noun

    ++  noun  ,*                                            ::  any noun

Used nowhere XX

    > `noun`~[1 2 3]
    [1 2 3 0]

++null

    ++  null  ,~                                            ::  null, nil, etc

Used nowhere XX

    > :type; *null
    ~
    %~

++port

XX move to ++ut

Type and location of core-shaped thing? XX Compiler Internals

Source

    ++  port  $:  p=axis                                    ::
                  $=  q                                     ::
                  $%  [%& p=type]                           ::
                      [%| p=axis q=(list ,[p=type q=foot])] ::
                  ==                                        ::
              ==                                            ::

Examples

    > *port
    [p=0 q=[%.y p=%void]]

++span

ASCII atom

A restricted text atom for canonical atom syntaxes. The prefix is ~.. There are no escape sequences except ~~, which means ~, and ~-, which means _. - and . encode themselves. No other characters besides numbers and lowercase letters are permitted.

Source

        ++  span  ,@ta                                     ::  text-atom (ASCII)

Examples

    > *span
    ~.

    > `@t`~.foo
    'foo'
    > `@t`~.foo.bar
    'foo.bar'
    > `@t`~.foo~~bar
    'foo~bar'
    > `@t`~.foo~-bar
    'foo_bar'
    > `@t`~.foo-bar
    'foo-bar'

++tiki

XX move to ++ut

Source

        ++  tiki                                                ::  test case

Examples

A `++wing` or `++hoon`.

    > (ream '=+  a=4  ?-(a @ ~)')
    [ %tsls
      p=[%ktts p=p=%a q=[%dtzy p=%ud q=4]]
        q
      [ %wthz
        p=[%.y p=~ q=~[%a]]
        q=~[[p=[%axil p=[%atom p=~.]] q=[%bczp p=%null]]]
      ]
    ]
    > (ream '=+  a=4  ?-(4 @ ~)')
    [ %tsls
      p=[%ktts p=p=%a q=[%dtzy p=%ud q=4]]
        q
      [ %wthz
        p=[%.n p=~ q=[%dtzy p=%ud q=4]]
        q=~[[p=[%axil p=[%atom p=~.]] q=[%bczp p=%null]]]
      ]
    ]

++toga

Tree of faces

A face, or tree of faces. A ++toga is applied to anything assigned using ^=.

XX move to ++ut and rune doc (for ^= examples)

Source

        ++  toga                                                ::  face control
                  [2 p=toga q=toga]                         ::  cell toga
              ==                                            ::

Examples

    > a=1
    a=1
    > (ream 'a=1')
    [%ktts p=p=%a q=[%dtzy p=%ud q=1]]
    > [a b]=[1 2 3]
    [a=1 b=[2 3]]
    > (ream '[a b]=[1 2 3]')
    [ %ktts
      p=[%2 p=p=%a q=p=%b]
      q=[%cltr p=~[[%dtzy p=%ud q=1] [%dtzy p=%ud q=2] [%dtzy p=%ud q=3]]]
    ]

    > [a ~]=[1 2 3]
    [a=1 2 3]
    > (ream '[a ~]=[1 2 3]')
    [ %ktts
      p=[%2 p=p=%a q=[%0 ~]]
      q=[%cltr p=~[[%dtzy p=%ud q=1] [%dtzy p=%ud q=2] [%dtzy p=%ud q=3]]]
    ]

++tone

Intermediate Nock computation result

Similar to ++toon, but stack trace is not yet rendered.

Source

        ++  tone  $%  [%0 p=*]                                  ::  success

Examples

    > (mink [[20 21] 0 3] ,~)
    [%0 p=21]

    > (mink [[0] !=(.^(cy//=main/1))] ,~)
    [%1 p=~[[31.075 1.685.027.454 1.852.399.981 49 0]]]
    > (path [31.075 1.685.027.454 1.852.399.981 49 0])
    /cy/~zod/main/1

    > (mink [[1 2] !=(~|(%hi +(.)))] ,~)
    [%2 p=~[[~.yelp 26.984]]]
    > (mink [[1 2] !=(!:(+(.)))] ,~)
    [ %2
        p
      ~[
        [ ~.spot
          [ [ 1.685.027.454
              7.959.156
              \/159.445.990.350.374.058.574.398.238.344.143.957.205.628.479.572.65\/
                8.112.403.878.526
              \/                                                                  \/
              0
            ]
            [1 20]
            1
            24
          ]
        ]
      ]
    ]

++tuna

XML template tree

An XML template tree.

Source

        ++  tuna                                                ::  tagflow
                  [%d p=hoon]                               ::  dynamic list
                  [%e p=hoon q=(list tuna)]                 ::  element
                  [%f p=(list tuna)]                        ::  subflow
              ==                                            ::

Examples

Leaf %a contains plain-text, %b an empty tag, %c a static list, %d a dynamic list, %e a full node element containing a hoon and a list of tuna, and %f is a empty node.

See also: ++sail


++tusk

List of expressions

List of ++hoons. In :*, for example, your contents is a ++tusk.

Source

        ++  tusk  (list hoon)                                   ::

Examples

    > (ream '[1 2 3]')
    [%cltr p=~[[%dtzy p=%ud q=1] [%dtzy p=%ud q=2] [%dtzy p=%ud q=3]]]
    > (tusk +:(ream '[1 2 3]'))
    ~[[%dtzy p=%ud q=1] [%dtzy p=%ud q=2] [%dtzy p=%ud q=3]]

++hoon

Expression

An expression, or AST.

See Rune section of Hoon reference


++tyke

List of 'maybe' hoons

List of ++unit ++hoon, or gaps left to be inferred, in ++path parsing. When you use a path such as /=main=/pub/src/doc the path is in fact a ++tyke, where the = are inferred from your current path.

Source

        ++  tyke  (list (unit hoon))                            ::

Examples

    > (scan "/==as=" porc:vast)
    [0 ~[~ ~ [~ [%dtzy p=%tas q=29.537]] ~]]
    > `tyke`+:(scan "/==as=" porc:vast)
    ~[~ ~ [~ [%dtzy p=%tas q=29.537]] ~]

++typo

Pointer for ++type

Pointer for ++type. ++typo preserves the previous ++type in your context when upating.

Source

        ++  typo  type                                          ::  old type

Examples

See also: ++seem, ++vise, ++type


++tyre

List, term hoon

Associative list of ++term ++hoon, used in jet hint processing.

Source

        ++  tyre  (list ,[p=term q=hoon])                       ::

++vase

Typed data. A ++vase is used wherever typed data is explicitly worked with.

Source

        ++  vase  ,[p=type q=*]                                 ::  type-value pair

Examples

    > `vase`!>(~)
    [p=[%cube p=0 q=[%atom p=%n]] q=0]

++vise

Convert during reboot

Used to convert from previously-typed data during reboot.

Source

    ++  vise  ,[p=typo q=*]                                 ::  old vase

Examples

See also: ++typo, ++seer


++wing

    ++  wing  (list limb)                                   ::

Address in subject. A ++wing is a path to a value in the subject. A term alone is the trivial case of a ++wing.

See also: ++hoon

    > (ream 'a.+.c')
    [%cnzz p=~[%a [%.y p=3] %c]]
    > (wing +:(ream 'a.+.c'))
    ~[%a [%.y p=3] %c]