@@ -6,30 +6,25 @@ navhome: /docs/
6# 2f: noun ordering
6# 2f: noun ordering
9−Alphabetic order
9+Alphabetical order
11−Computes whether `a` and `b` are in alphabetical order, producing a
11+Computes whether `a` and `b` are in alphabetical order, producing a flag.
14−Accepts
13+#### Accepts
17`a` is a noun.
15`a` is a noun.
19`b` is a noun.
17`b` is a noun.
21−Produces
19+#### Produces
24−A boolean atom.
21+A flag.
30− ++ aor :: a-order
25+ ++ aor
32− |= {a/* b/*}
27+ |= [a=* b=*]
34 ?: =(a b) &
29 ?: =(a b) &
35 ?. ?=(@ a)
30 ?. ?=(@ a)
@@ -44,24 +39,32 @@ Source
44 $(a (rsh 3 1 a), b (rsh 3 1 b))
39 $(a (rsh 3 1 a), b (rsh 3 1 b))
48−Examples
42+#### Examples
51 > (aor 'a' 'b')
44 > (aor 'a' 'b')
53 > (aor 'b' 'a')
47 > (aor 'b' 'a')
55 > (aor "foo" "bar")
53 > (aor "foo" "bar")
57 > (aor "bar" "foo")
56 > (aor "bar" "foo")
59 > (aor "abcdefz" "abcdefa")
59 > (aor "abcdefz" "abcdefa")
61 > (aor "abcdefa" "abcdefz")
62 > (aor "abcdefa" "abcdefz")
63 > (aor 10.000 17.000)
65 > (aor 10.000 17.000)
65 > (aor 10 9)
68 > (aor 10 9)
@@ -72,27 +75,23 @@ Examples
73Numeric order
76Numeric order
75−Computes whether `a` and `b` are in ascending numeric order, producing a
78+Computes whether `a` and `b` are in ascending numeric order, producing a flag.
78−Accepts
80+#### Accepts
81`a` is a noun.
82`a` is a noun.
83`b` is a noun.
84`b` is a noun.
85−Produces
86+#### Produces
88−A boolean atom.
88+A flag.
93− ++ dor :: d-order
92+ ++ dor
95− |= {a/* b/*}
94+ |= [a=* b=*]
97 ?: =(a b) &
96 ?: =(a b) &
98 ?. ?=(@ a)
97 ?. ?=(@ a)
@@ -104,22 +103,34 @@ Source
104 (lth a b)
103 (lth a b)
107−Examples
106+#### Examples
110 > (dor 1 2)
108 > (dor 1 2)
112 > (dor 2 1)
111 > (dor 2 1)
114 > (dor ~[1 2 3] ~[1 2 4])
114 > (dor ~[1 2 3] ~[1 2 4])
116 > (dor ~[1 2 4] ~[1 2 3])
117 > (dor ~[1 2 4] ~[1 2 3])
118− > (dor (limo ~[99 100 10.000]) ~[99 101 10.000])
120+ > (dor `(list @)`~[99 100 10.000] ~[99 101 10.000])
120− > (dor ~[99 101 10.999] (limo ~[99 100 10.000]))
123+ > (dor ~[99 101 10.999] `(list @)`~[99 100 10.000])
128+If `a` and `b` are both atoms, `dor` is equivalent to [`lte`](../1a). If they're
129+cells, `dor` recurses on the heads, and then if the heads are the same it checks
132+If one sample is a cell and the other is an atom, the cell sample is treated as
@@ -127,26 +138,27 @@ Examples
128Hash order
139Hash order
130−XX revisit
141+Computes whether of `(mug a)` and `(mug b)` are in ascending numeric order,
142+producing a flag. If the `mug` hashes are equal, `a` and `b` are compared by
145+[`mug`](../2e) is the the 31-bit nonzero FNV-1a hash algorithm.
132−Accepts
147+#### Accepts
135`a` is a noun.
149`a` is a noun.
137`b` is a noun.
151`b` is a noun.
139−Produces
153+#### Produces
142−A boolean atom.
155+A flag.
144−Source
157+#### Source
147− ++ gor :: g-order
159+ ++ gor
149− |= {a/* b/*}
161+ |= [a=* b=*]
151 =+ [c=(mug a) d=(mug b)]
163 =+ [c=(mug a) d=(mug b)]
152 ?: =(c d)
164 ?: =(c d)
@@ -154,61 +166,77 @@ Source
154 (lth c d)
166 (lth c d)
157−Examples
169+#### Examples
160 > (gor 'd' 'c')
171 > (gor 'd' 'c')
165 > `@ud`'d'
180 > `@ud`'d'
167 > `@ud`'c'
183 > `@ud`'c'
169− > (mug 'd')
186+ > (mug 'd')
170 1.628.185.714
187 1.628.185.714
171 > (mug 'c')
189 > (mug 'c')
172 1.712.073.811
190 1.712.073.811
173 > (gor 'd' 'c')
192 > (gor 'd' 'c')
175 > (gor 'c' 'd')
195 > (gor 'c' 'd')
177 > (gor "foo" "bar")
198 > (gor "foo" "bar")
179− > (gor (some 10) (limo [1 2 3 ~]))
201+ > (gor (some 10) `(list @)`[1 2 3 ~])
206+`map`s use `gor` on the key for horizontal ordering and `vor` for
207+vertical order. `map`s only look at the keys (the head of the key-value pair
208+elements) for ordering.
185### `++hor`
211### `++hor`
187−Hash order
213+Horizontal hash order
215+If `a` and `b` are atoms, they are computed as samples of `gor`, producing a
189−XX revisit
218+If `a` and `b` are cells, `hor` checks to see if their heads are equal. If their
219+heads are equal, `gor` is computed on their tails, producing a flag. If their
220+heads are not equal, `gor` is computed on their heads, producing a flag.
191−Recursive hash comparator gate.
222+If `a` is an atom and `b` is not, then `%.y` is produced. If `b` is an atom and
223+`a` is not, `%.n` is produced.
193−Accepts
225+#### Accepts
196`a` is a noun.
227`a` is a noun.
198`b` is a noun.
229`b` is a noun.
200−Produces
231+#### Produces
203−A boolean atom.
233+A flag.
209− ++ hor :: h-order
237+ ++ hor
211− |= {a/* b/*}
239+ |= [a=* b=*]
213 ?: ?=(@ a)
241 ?: ?=(@ a)
214 ?. ?=(@ b) &
242 ?. ?=(@ b) &
@@ -217,46 +245,144 @@ Source
217 ?: =(-.a -.b)
245 ?: =(-.a -.b)
218 (gor +.a +.b)
246 (gor +.a +.b)
219 (gor -.a -.b)
247 (gor -.a -.b)
223−Examples
250+#### Examples
226 > (hor . 1)
252 > (hor . 1)
228 > (hor 1 2)
255 > (hor 1 2)
230 > (hor "abc" "cba")
258 > (hor "abc" "cba")
232 > (hor 'c' 'd')
261 > (hor 'c' 'd')
270+ > (hor 500.000.000 "foo")
273+ > (hor "foo" 500.000.000)
279+ > (gor `(list @)`[0 ~] 1)
282+ > (hor `(list @)`[50 500 5.000 ~] 1)
288+Sets (+set, +in) use `hor` for their horizontal order and `vor` for their
289+vertical order. See [`apt:in`](../2h) to see how a set verifies its correctness.
290+`vor` is used to verify.
297+Computes whether the corresponding legs of `a` and `b` are in ascending
298+numeric order, producing a flag.
336+ > (lor `(list @)`[1 2 3 ~] `(list @)`[1 2 3 4 ~])
339+ > (lor `(list @)`[1 2 3 ~] `(list @)`[1 2 2 ~])
342+ > (lor `(list @)`[1 2 3 ~] `(list @)`[2 2 ~])
345+ > (lor [2 2 5] [1 5 9 8])
348+ > (lor [1 5 8] [1 5 9 8])
351+ > (lor [1 2 3] [1 2])
357+`lor` is no longer used internally.
238### `++vor`
360### `++vor`
240−Double hash comparator gate.
362+Vertical order
364+Computes whether the double-hashes `(mug (mug a))` and `(mug (mug b))` are in
365+ascending numeric order, producing a flag. If the double-`mug` hashes are
366+equal, `a` and `b` are compared by `dor` instead.
242−XX revisit
368+[`mug`](../2e) is the the 31-bit nonzero FNV-1a hash algorithm.
244−Accepts
371+#### Accepts
247`a` is a noun
373`a` is a noun
249`b` is a noun
375`b` is a noun
251−Produces
377+#### Produces
254−Source
381+#### Source
257− ++ vor :: v-order
383+ ++ vor
259− |= {a/* b/*}
385+ |= [a=* b=*]
261 =+ [c=(mug (mug a)) d=(mug (mug b))]
387 =+ [c=(mug (mug a)) d=(mug (mug b))]
262 ?: =(c d)
388 ?: =(c d)
@@ -264,16 +390,33 @@ Source
264 (lth c d)
390 (lth c d)
267−Examples
393+#### Examples
270 > (vor 'f' 'g')
395 > (vor 'f' 'g')
398+ > [(mug 'f') (mug 'g')]
399+ [1.661.740.952 1.644.963.335]
401+ > [(mug (mug 'f')) (mug (mug 'g'))]
402+ [261.421.509 1.861.258.547]
272 > (vor 'a' 'z')
404 > (vor 'a' 'z')
274 > (vor 43.326 41.106)
407 > (vor 43.326 41.106)
413+Maps, sets, and queues all use `vor` to check for vertical ordering. Maps and
414+sets also use `gor` and `hor` for horizontal order, respectively, but queues use
415+vertical ordering alone.
417+Since hashing removes correlation, double-`mug`ging with `vor` removes
418+correlation with single-`mug`ged `hor`. Vertical order becomes uncorrelated
419+with horizontal order.