on master help sign in
Update 2f
005ec77rmariani
docs/hoon/library/2f.md+44−12
@@ -6,7 +6,7 @@ navhome: /docs/
6# 2f: noun ordering
6# 2f: noun ordering
7### `++aor`
7### `++aor`
8
8
9−Alphabetic order
9+Alphabetical order
10
10
11Computes whether `a` and `b` are in alphabetical order, producing a flag.
11Computes whether `a` and `b` are in alphabetical order, producing a flag.
12
12
@@ -123,6 +123,14 @@ A flag.
123 > (dor ~[99 101 10.999] `(list @)`~[99 100 10.000])
123 > (dor ~[99 101 10.999] `(list @)`~[99 100 10.000])
124 %.n
124 %.n
125
125
126+#### Discussion
127+
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
130+the tails.
131+
132+If one sample is a cell and the other is an atom, the cell sample is treated as
133+"greater."
126
134
127
135
128***
136***
@@ -130,8 +138,9 @@ A flag.
130
138
131Hash order
139Hash order
132
140
133−Computes whether the products of `a` and `b` hashed with `mug` are in
141+Computes whether of `(mug a)` and `(mug b)` are in ascending numeric order,
134−ascending numeric order, producing a flag.
142+producing a flag. If the `mug` hashes are equal, `a` and `b` are compared by
143+`dor` instead.
135
144
136[`mug`](../2e) is the the 31-bit nonzero FNV-1a hash algorithm.
145[`mug`](../2e) is the the 31-bit nonzero FNV-1a hash algorithm.
137
146
@@ -192,20 +201,24 @@ A flag.
192 > (gor (some 10) `(list @)`[1 2 3 ~])
201 > (gor (some 10) `(list @)`[1 2 3 ~])
193 %.n
202 %.n
194
203
204+#### Discussion
195
205
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.
196
209
197***
210***
198### `++hor`
211### `++hor`
199
212
200−Head/tail hash order
213+Horizontal hash order
214+
215+If `a` and `b` are atoms, they are computed as samples of `gor`, producing a
216+flag.
201
217
202If `a` and `b` are cells, `hor` checks to see if their heads are equal. If their
218If `a` and `b` are cells, `hor` checks to see if their heads are equal. If their
203heads are equal, `gor` is computed on their tails, producing a flag. If their
219heads are equal, `gor` is computed on their tails, producing a flag. If their
204heads are not equal, `gor` is computed on their heads, producing a flag.
220heads are not equal, `gor` is computed on their heads, producing a flag.
205
221
206−If `a` and `b` are atoms, they are computed as samples of `gor`, producing a
207−flag.
208−
209If `a` is an atom and `b` is not, then `%.y` is produced. If `b` is an atom and
222If `a` is an atom and `b` is not, then `%.y` is produced. If `b` is an atom and
210`a` is not, `%.n` is produced.
223`a` is not, `%.n` is produced.
211
224
@@ -270,6 +283,11 @@ A flag.
270 %.n
283 %.n
271
284
272
285
286+#### Discussion
287+
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.
273
291
274***
292***
275### `++lor`
293### `++lor`
@@ -312,7 +330,7 @@ A flag.
312 > (lor 2 1)
330 > (lor 2 1)
313 %.n
331 %.n
314
332
315− > (lor 9 [1 2]) :: lor computes cells as greater than atoms
333+ > (lor 9 [1 2])
316 %.y
334 %.y
317
335
318 > (lor `(list @)`[1 2 3 ~] `(list @)`[1 2 3 4 ~])
336 > (lor `(list @)`[1 2 3 ~] `(list @)`[1 2 3 4 ~])
@@ -327,21 +345,25 @@ A flag.
327 > (lor [2 2 5] [1 5 9 8])
345 > (lor [2 2 5] [1 5 9 8])
328 %.n
346 %.n
329
347
330− > (lor [1 4 8] [1 5 9 8])
348+ > (lor [1 5 8] [1 5 9 8])
331 %.y
349 %.y
332
350
333 > (lor [1 2 3] [1 2])
351 > (lor [1 2 3] [1 2])
334 !! exit
352 !! exit
335
353
336
354
355+#### Discussion
356+
357+`lor` is no longer used internally.
337
358
338***
359***
339### `++vor`
360### `++vor`
340
361
341−Double hash order
362+Vertical order
342
363
343−Computes whether the products of `a` and `b` double-hashed with `mug` are in
364+Computes whether the double-hashes `(mug (mug a))` and `(mug (mug b))` are in
344−ascending numeric order, producing a flag.
365+ascending numeric order, producing a flag. If the double-`mug` hashes are
366+equal, `a` and `b` are compared by `dor` instead.
345
367
346[`mug`](../2e) is the the 31-bit nonzero FNV-1a hash algorithm.
368[`mug`](../2e) is the the 31-bit nonzero FNV-1a hash algorithm.
347
369
@@ -386,5 +408,15 @@ A flag.
386 %.n
408 %.n
387
409
388
410
411+#### Discussion
412+
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.
416+
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.
420+
389
421
390***
422***