on master help sign in
Update 2f
6e48502rmariani
docs/hoon/library/2f.md+183−72
@@ -8,28 +8,23 @@ navhome: /docs/
8
8
9Alphabetic order
9Alphabetic order
10
10
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.
12−boolean.
13
12
14−Accepts
13+#### Accepts
15−-------
16
14
17`a` is a noun.
15`a` is a noun.
18
16
19`b` is a noun.
17`b` is a noun.
20
18
21−Produces
19+#### Produces
22−--------
23
20
24−A boolean atom.
21+A flag.
25
22
23+#### Source
26
24
27−Source
28−------
29−
30− ++ aor :: a-order
25+ ++ aor
31 ~/ %aor
26 ~/ %aor
32− |= {a/* b/*}
27+ |= [a=* b=*]
33 ^- ?
28 ^- ?
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))
45 (lth c d)
40 (lth c d)
46
41
47−
48−Examples
42+#### Examples
49−--------
50
43
51 > (aor 'a' 'b')
44 > (aor 'a' 'b')
52 %.y
45 %.y
46+
53 > (aor 'b' 'a')
47 > (aor 'b' 'a')
54 %.n
48 %.n
49+
50+ > (aor 'a' 'a')
51+ %.y
52+
55 > (aor "foo" "bar")
53 > (aor "foo" "bar")
56 %.n
54 %.n
55+
57 > (aor "bar" "foo")
56 > (aor "bar" "foo")
58 %.y
57 %.y
58+
59 > (aor "abcdefz" "abcdefa")
59 > (aor "abcdefz" "abcdefa")
60 %.n
60 %.n
61+
61 > (aor "abcdefa" "abcdefz")
62 > (aor "abcdefa" "abcdefz")
62 %.y
63 %.y
64+
63 > (aor 10.000 17.000)
65 > (aor 10.000 17.000)
64 %.y
66 %.y
67+
65 > (aor 10 9)
68 > (aor 10 9)
66 %.n
69 %.n
67
70
@@ -72,27 +75,23 @@ Examples
72
75
73Numeric order
76Numeric order
74
77
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.
76−boolean.
77
79
78−Accepts
80+#### Accepts
79−-------
80
81
81`a` is a noun.
82`a` is a noun.
82
83
83`b` is a noun.
84`b` is a noun.
84
85
85−Produces
86+#### Produces
86−--------
87
87
88−A boolean atom.
88+A flag.
89
89
90−Source
90+#### Source
91−------
92
91
93− ++ dor :: d-order
92+ ++ dor
94 ~/ %dor
93 ~/ %dor
95− |= {a/* b/*}
94+ |= [a=* b=*]
96 ^- ?
95 ^- ?
97 ?: =(a b) &
96 ?: =(a b) &
98 ?. ?=(@ a)
97 ?. ?=(@ a)
@@ -104,20 +103,24 @@ Source
104 (lth a b)
103 (lth a b)
105
104
106
105
107−Examples
106+#### Examples
108−--------
109
107
110 > (dor 1 2)
108 > (dor 1 2)
111 %.y
109 %.y
110+
112 > (dor 2 1)
111 > (dor 2 1)
113 %.n
112 %.n
113+
114 > (dor ~[1 2 3] ~[1 2 4])
114 > (dor ~[1 2 3] ~[1 2 4])
115 %.y
115 %.y
116+
116 > (dor ~[1 2 4] ~[1 2 3])
117 > (dor ~[1 2 4] ~[1 2 3])
117 %.n
118 %.n
119+
118− > (dor (limo ~[99 100 10.000]) ~[99 101 10.000])
120+ > (dor `(list @)`~[99 100 10.000] ~[99 101 10.000])
119 %.y
121 %.y
122+
120− > (dor ~[99 101 10.999] (limo ~[99 100 10.000]))
123+ > (dor ~[99 101 10.999] `(list @)`~[99 100 10.000])
121 %.n
124 %.n
122
125
123
126
@@ -127,26 +130,26 @@ Examples
127
130
128Hash order
131Hash order
129
132
130−XX revisit
133+Computes whether the products of `a` and `b` hashed with `mug` are in
134+ascending numeric order, producing a flag.
135+
136+[`mug`](../2e) is the the 31-bit nonzero FNV-1a hash algorithm.
131
137
132−Accepts
138+#### Accepts
133−-------
134
139
135`a` is a noun.
140`a` is a noun.
136
141
137`b` is a noun.
142`b` is a noun.
138
143
139−Produces
144+#### Produces
140−--------
141
145
142−A boolean atom.
146+A flag.
143
147
144−Source
148+#### Source
145−------
146
149
147− ++ gor :: g-order
150+ ++ gor
148 ~/ %gor
151 ~/ %gor
149− |= {a/* b/*}
152+ |= [a=* b=*]
150 ^- ?
153 ^- ?
151 =+ [c=(mug a) d=(mug b)]
154 =+ [c=(mug a) d=(mug b)]
152 ?: =(c d)
155 ?: =(c d)
@@ -154,29 +157,39 @@ Source
154 (lth c d)
157 (lth c d)
155
158
156
159
157−Examples
160+#### Examples
158−--------
159
161
160 > (gor 'd' 'c')
162 > (gor 'd' 'c')
161 %.y
163 %.y
164+
162 > 'd'
165 > 'd'
163 'd'
166 'd'
167+
164 > 'c'
168 > 'c'
169+ 'c'
170+
165 > `@ud`'d'
171 > `@ud`'d'
166 100
172 100
173+
167 > `@ud`'c'
174 > `@ud`'c'
168 99
175 99
176+
169− > (mug 'd')
177+ > (mug 'd')
170 1.628.185.714
178 1.628.185.714
179+
171 > (mug 'c')
180 > (mug 'c')
172 1.712.073.811
181 1.712.073.811
182+
173 > (gor 'd' 'c')
183 > (gor 'd' 'c')
174 %.y
184 %.y
185+
175 > (gor 'c' 'd')
186 > (gor 'c' 'd')
176 %.n
187 %.n
188+
177 > (gor "foo" "bar")
189 > (gor "foo" "bar")
178 %.n
190 %.n
191+
179− > (gor (some 10) (limo [1 2 3 ~]))
192+ > (gor (some 10) `(list @)`[1 2 3 ~])
180 %.n
193 %.n
181
194
182
195
@@ -184,31 +197,33 @@ Examples
184***
197***
185### `++hor`
198### `++hor`
186
199
187−Hash order
200+Head/tail hash order
201+
202+If `a` and `b` are cells, `hor` checks to see if their heads are equal. If their
203+heads are equal, `gor` is computed on their tails, producing a flag. If their
204+heads are not equal, `gor` is computed on their heads, producing a flag.
188
205
189−XX revisit
206+If `a` and `b` are atoms, they are computed as samples of `gor`, producing a
207+flag.
190
208
191−Recursive hash comparator gate.
209+If `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.
192
211
193−Accepts
212+#### Accepts
194−-------
195
213
196`a` is a noun.
214`a` is a noun.
197
215
198`b` is a noun.
216`b` is a noun.
199
217
200−Produces
218+#### Produces
201−--------
202
219
203−A boolean atom.
220+A flag.
204
221
222+#### Source
205
223
206−Source
207−------
208−
209− ++ hor :: h-order
224+ ++ hor
210 ~/ %hor
225 ~/ %hor
211− |= {a/* b/*}
226+ |= [a=* b=*]
212 ^- ?
227 ^- ?
213 ?: ?=(@ a)
228 ?: ?=(@ a)
214 ?. ?=(@ b) &
229 ?. ?=(@ b) &
@@ -217,46 +232,135 @@ Source
217 ?: =(-.a -.b)
232 ?: =(-.a -.b)
218 (gor +.a +.b)
233 (gor +.a +.b)
219 (gor -.a -.b)
234 (gor -.a -.b)
220− ::
221
235
222
236
223−Examples
237+#### Examples
224−--------
225
238
226 > (hor . 1)
239 > (hor . 1)
227 %.n
240 %.n
241+
228 > (hor 1 2)
242 > (hor 1 2)
229 %.y
243 %.y
244+
230 > (hor "abc" "cba")
245 > (hor "abc" "cba")
231 %.y
246 %.y
247+
232 > (hor 'c' 'd')
248 > (hor 'c' 'd')
233 %.n
249 %.n
234
250
251+ > (hor 100 [1 1])
252+ %.y
253+
254+ > (hor [1 1] 100)
255+ %.n
256+
257+ > (hor 500.000.000 "foo")
258+ %.y
259+
260+ > (hor "foo" 500.000.000)
261+ %.n
262+
263+ > (hor 0 "foo")
264+ %.y
265+
266+ > (gor `(list @)`[0 ~] 1)
267+ %.n
268+
269+ > (hor `(list @)`[50 500 5.000 ~] 1)
270+ %.n
271+
272+
273+
274+***
275+### `++lor`
276+
277+Leg order
278+
279+Computes whether the corresponding legs of `a` and `b` are in ascending
280+numeric order, producing a flag.
281+
282+#### Accepts
283+
284+`a` is a noun.
285+
286+`b` is a noun.
287+
288+#### Accepts
289+
290+A flag.
291+
292+#### Source
293+
294+ ++ lor
295+ ~/ %lor
296+ |= [a=* b=*]
297+ ^- ?
298+ ?: =(a b) &
299+ ?@ a
300+ ?^ b &
301+ (lth a b)
302+ ?: =(-.a -.b)
303+ $(a +.a, b +.b)
304+ $(a -.a, b -.b)
305+
306+
307+#### Examples
308+
309+ > (lor 1 2)
310+ %.y
311+
312+ > (lor 2 1)
313+ %.n
314+
315+ > (lor 9 [1 2]) :: lor computes cells as greater than atoms
316+ %.y
317+
318+ > (lor `(list @)`[1 2 3 ~] `(list @)`[1 2 3 4 ~])
319+ %.y
320+
321+ > (lor `(list @)`[1 2 3 ~] `(list @)`[1 2 2 ~])
322+ %.n
323+
324+ > (lor `(list @)`[1 2 3 ~] `(list @)`[2 2 ~])
325+ %.y
326+
327+ > (lor [2 2 5] [1 5 9 8])
328+ %.n
329+
330+ > (lor [1 4 8] [1 5 9 8])
331+ %.y
332+
333+ > (lor [1 2 3] [1 2])
334+ !! exit
335+
235
336
236
337
237***
338***
238### `++vor`
339### `++vor`
239
340
240−Double hash comparator gate.
341+Double hash order
342+
343+Computes whether the products of `a` and `b` double-hashed with `mug` are in
344+ascending numeric order, producing a flag.
345+
346+[`mug`](../2e) is the the 31-bit nonzero FNV-1a hash algorithm.
241
347
242−XX revisit
243
348
244−Accepts
349+#### Accepts
245−-------
246
350
247`a` is a noun
351`a` is a noun
248
352
249`b` is a noun
353`b` is a noun
250
354
251−Produces
355+#### Produces
252−-------
253
356
254−Source
357+A flag.
255−------
256
358
359+#### Source
360+
257− ++ vor :: v-order
361+ ++ vor
258 ~/ %vor
362 ~/ %vor
259− |= {a/* b/*}
363+ |= [a=* b=*]
260 ^- ?
364 ^- ?
261 =+ [c=(mug (mug a)) d=(mug (mug b))]
365 =+ [c=(mug (mug a)) d=(mug (mug b))]
262 ?: =(c d)
366 ?: =(c d)
@@ -264,13 +368,20 @@ Source
264 (lth c d)
368 (lth c d)
265
369
266
370
267−Examples
371+#### Examples
268−--------
269
372
270 > (vor 'f' 'g')
373 > (vor 'f' 'g')
271 %.y
374 %.y
375+
376+ > [(mug 'f') (mug 'g')]
377+ [1.661.740.952 1.644.963.335]
378+
379+ > [(mug (mug 'f')) (mug (mug 'g'))]
380+ [261.421.509 1.861.258.547]
381+
272 > (vor 'a' 'z')
382 > (vor 'a' 'z')
273 %.n
383 %.n
384+
274 > (vor 43.326 41.106)
385 > (vor 43.326 41.106)
275 %.n
386 %.n
276
387