on master help sign in
Update 1a
3578156rmariani
docs/hoon/library/1a.md+136−224
@@ -10,30 +10,26 @@ Add
10
10
11Produces the sum of `a` and `b`.
11Produces the sum of `a` and `b`.
12
12
13−Accepts
13+#### Accepts
14−-------
15
14
16`a` is an atom.
15`a` is an atom.
17
16
18`b` is an atom.
17`b` is an atom.
19
18
20−Produces
19+#### Produces
21−--------
22
20
23An atom.
21An atom.
24
22
25−Source
23+#### Source
26−------
27
24
28− ++ add
25+ ++ add
29 ~/ %add
26 ~/ %add
30 |= [a=@ b=@]
27 |= [a=@ b=@]
31 ^- @
28 ^- @
32 ?: =(0 a) b
29 ?: =(0 a) b
33 $(a (dec a), b +(b))
30 $(a (dec a), b +(b))
34−::
31+
35−Examples
32+#### Examples
36−--------
37
33
38 > (add 2 2)
34 > (add 2 2)
39 4
35 4
@@ -44,15 +40,15 @@ Examples
44 > (add 1.333 (mul 2 2))
40 > (add 1.333 (mul 2 2))
45 1.337
41 1.337
46
42
47− > `@`'a' ::`'a'` is an atom represented as a different data type.
48− 97 We cast it to the aura `@` to see what its integer representation is.
49 > (add 'a' 4)
43 > (add 'a' 4)
50 101
44 101
45+
51− (add 'a' 'b')
46+ > (add 'a' 'b')
52 195
47 195
53
48
54− > (add 0xc 0xf) ::`0xc` and `0xf` are of the hexadecimal soft atom type (`@ux`).
49+ > (add 0xc 0xf)
55 27
50 27
51+
56 > `@ux`(add 0xc 0xf)
52 > `@ux`(add 0xc 0xf)
57 0x1b
53 0x1b
58
54
@@ -63,31 +59,27 @@ Decrement
63
59
64Decrements `a` by `1`.
60Decrements `a` by `1`.
65
61
66−Accepts
62+#### Accepts
67−-------
68
63
69`a` is an atom.
64`a` is an atom.
70
65
71−Produces
66+#### Produces
72−--------
73
67
74An atom.
68An atom.
75
69
76−Source
70+#### Source
77−------
78
71
79− ++ dec
72+ ++ dec
80 ~/ %dec
73 ~/ %dec
81 |= a=@
74 |= a=@
82− ~_ leaf+"decrement-underflow"
75+ ~| %decrement-underflow
83 ?< =(0 a)
76 ?< =(0 a)
84 =+ b=0
77 =+ b=0
85 |- ^- @
78 |- ^- @
86 ?: =(a +(b)) b
79 ?: =(a +(b)) b
87 $(b +(b))
80 $(b +(b))
88−::
81+
89−Examples
82+#### Examples
90−--------
91
83
92 > (dec 7)
84 > (dec 7)
93 6
85 6
@@ -107,29 +99,27 @@ Examples
107 0xb
99 0xb
108
100
109
101
102+
110***
103***
111### `++div`
104### `++div`
112
105
113Divide
106Divide
114
107
115−Computes `a` divided by `b`. Only a whole number, without the remainder, is produced.
108+Computes `a` divided by `b` without remainder.
116
109
117−Accepts
110+#### Accepts
118−-------
119
111
120`a` is an atom.
112`a` is an atom.
121
113
122`b` is an atom.
114`b` is an atom.
123
115
124−Produces
116+#### Produces
125−--------
126
117
127An atom.
118An atom.
128
119
129−Source
120+#### Source
130−------
131
121
132− ++ div
122+ ++ div
133 ~/ %div
123 ~/ %div
134 |: [a=`@`1 b=`@`1]
124 |: [a=`@`1 b=`@`1]
135 ^- @
125 ^- @
@@ -139,9 +129,10 @@ Source
139 |-
129 |-
140 ?: (lth a b) c
130 ?: (lth a b) c
141 $(a (sub a b), c +(c))
131 $(a (sub a b), c +(c))
142− ::
132+
133+
143−Examples
134+#### Examples
144−--------
135+
145
136
146 > (div 4 2)
137 > (div 4 2)
147 2
138 2
@@ -161,25 +152,6 @@ Examples
161
152
162 > (div 0x9f 0x29)
153 > (div 0x9f 0x29)
163 6
154 6
164− > `@`0x9f ::`0x9f` is an atom represented in the hexadecimal soft atom type (`@ux`).
165− 159
166− > `@`0x29
167− 41
168−
169− > (div 0x29 0x9f)
170− 0
171−
172− > (div ~sibtel-tallyd ~zod)
173− ! exit
174− > `@`~sibtel-tallyd
175− 7.303.014
176− > `@`~zod ::the above operation returned an error because `~zod` is a representation of `0`.
177− 0
178−
179− > `@p`2 ::this casts `2` to `@p` to produce the ship name which represents that atom.
180− ~bud
181− > (div ~sibtel-tallyd ~bud)
182− > 3.651.507
183
155
184
156
185***
157***
@@ -187,24 +159,28 @@ Examples
187
159
188Divide with remainder
160Divide with remainder
189
161
190−Computes `a` divided by `b` and the remainder of that operation.
162+Computes `a` divided by `b`, producing the quotient and the remainder.
191
163
164+#### Accepts
165+
166+`a` is an atom.
167+
168+`b` is an atom.
169+
192−Produces
170+#### Produces
193−-------
194
171
195A cell of atoms.
172A cell of atoms.
196
173
197−Source
174+#### Source
198−------
175+
199−
200− ++ dvr
176+ ++ dvr
201− ~/ %dvr
177+ ~/ %dvr
202− |= [a=@ b=@]
178+ |= [a=@ b=@]
203− ^- [p=@ q=@]
179+ ^- [p=@ q=@]
204− [(div a b) (mod a b)]
180+ [(div a b) (mod a b)]
205− ::
181+
206−Examples
182+#### Examples
207−--------
183+
208 > (dvr 17 8)
184 > (dvr 17 8)
209 [p=2 q=1]
185 [p=2 q=1]
210
186
@@ -219,45 +195,38 @@ Examples
219
195
220 > (dvr 'ab 'a')
196 > (dvr 'ab 'a')
221 [p=259 q=62]
197 [p=259 q=62]
222− > `@`'a' ::`a` is an atom represented as a different data type.
198+ > `@`'a'
223− 97 We can cast it to the aura `@` to see what its integer representation is.
199+ 97
224 > `@`'ab'
200 > `@`'ab'
225 25.185
201 25.185
226
202
227− > (dvr '' 'a')
228− [p=0 q=0]
229−
230−
231***
203***
232### `++gte`
204### `++gte`
233
205
234Greater-than/equal
206Greater-than/equal
235
207
236−Tests whether a number `a` is greater than or equal a number `b`.
208+Tests whether `a` is greater than or equal to `b`.
237
209
238−Accepts
210+#### Accepts
239−-------
240
211
241`a` is an atom.
212`a` is an atom.
242
213
243`b` is an atom.
214`b` is an atom.
244
215
245−Produces
216+#### Produces
246−--------
247
217
248−A flag. Our version of a boolean, except that `0` is yes/true and `1` is no/false.
218+A flag.
249
219
250−Source
220+#### Source
251−------
252
221
253 ++ gte
222 ++ gte
254 ~/ %gte
223 ~/ %gte
255 |= [a=@ b=@]
224 |= [a=@ b=@]
256 ^- ?
225 ^- ?
257 !(lth a b)
226 !(lth a b)
258− ::
227+
228+
259−Examples
229+#### Examples
260−--------
261
230
262 > (gte 100 10)
231 > (gte 100 10)
263 %.y
232 %.y
@@ -268,18 +237,6 @@ Examples
268 > (gte 3 4)
237 > (gte 3 4)
269 %.n
238 %.n
270
239
271− > `@`'h' ::`h` is an atom represented as a `cord`, one of many different soft atom types.
272− 104 ::We can cast it to the mold `@` to see what its integer representation is.
273− > `@`'b'
274− 98
275− > (gte 'h' 'b')
276− %.y
277−
278− > (gte '0xc' '0xf')
279− %.n
280−
281− > (gte '0xc' '0xc')
282− %.y
283
240
284
241
285***
242***
@@ -289,50 +246,35 @@ Greater-than
289
246
290Tests whether `a` is greater than `b`.
247Tests whether `a` is greater than `b`.
291
248
292−Accepts
249+#### Accepts
293−-------
294
250
295`a` is an atom.
251`a` is an atom.
296
252
297`b` is an atom.
253`b` is an atom.
298
254
299−Produces
255+#### Produces
300−--------
301
256
302−A flag; our version of a boolean, except that `0` is yes/true and `1` is no/false.
257+A flag.
303
258
304−Source
259+#### Source
305−------
306
260
307− ++ gth
261+ ++ gth
308 ~/ %gth
262 ~/ %gth
309 |= [a=@ b=@]
263 |= [a=@ b=@]
310 ^- ?
264 ^- ?
311 !(lte a b)
265 !(lte a b)
312− ::
313−Examples
314−--------
315− > (gth 2 1)
316− %.y
317
266
318− > (gth 1 2)
267+
319− %.n
268+
269+#### Examples
320
270
321 > (gth 'd' 'c')
271 > (gth 'd' 'c')
322 %.y
272 %.y
323− > `@`'d' ::`d` is an atom represented as a `cord`, one of many different soft atom types.
324− 100 ::We can cast it to the mold `@` to see what its integer representation is.
325− > `@`'c'
326− 99
327
273
328− > (gth 'doug' 'catherine')
274+ > (gth ~h1 ~m61)
329 %.n
275 %.n
330− > `@`'doug'
331− 1.735.749.476
332− > `@`'catherine'
333− 1.871.077.167.441.261.125.987
334
276
335− > (gth ~h1 ~m61) ::~h1 and ~m61 are both relative dates. Cast an atom to `@dr` to see its representation in that soft atom type.
277+ > (gth 'steak' 'brisket')
336 %.n
278 %.n
337
279
338
280
@@ -343,28 +285,25 @@ Less-than/equal
343
285
344Tests whether `a` is less than or equal to `b`.
286Tests whether `a` is less than or equal to `b`.
345
287
346−Accepts
288+#### Accepts
347−-------
348
289
349`a` is an atom.
290`a` is an atom.
350
291
351`b` is an atom.
292`b` is an atom.
352
293
353−Produces
294+#### Produces
354−--------
355
295
356−A flag; our version of a boolean, except that `0` is yes/true and `1` is no/false.
296+A flag.
357
297
358−Source
298+#### Source
359−------
360
299
361 ++ lte
300 ++ lte
362 ~/ %lte
301 ~/ %lte
363 |= [a=@ b=@]
302 |= [a=@ b=@]
364 |(=(a b) (lth a b))
303 |(=(a b) (lth a b))
365− ::
304+
305+
366−Examples
306+#### Examples
367−--------
368
307
369 > (lte 4 5)
308 > (lte 4 5)
370 %.y
309 %.y
@@ -378,6 +317,7 @@ Examples
378 > (lte 0 0)
317 > (lte 0 0)
379 %.y
318 %.y
380
319
320+
381 > (lte 'a' 'b')
321 > (lte 'a' 'b')
382 %.y
322 %.y
383 > `@`'a'
323 > `@`'a'
@@ -388,10 +328,11 @@ Examples
388 > (lte 'abraham' 'bob')
328 > (lte 'abraham' 'bob')
389 %.n
329 %.n
390
330
391− > (lte ~m61 ~h1) ::~m61 and ~h1 are both relative dates. Cast an atom to `@dr` to see its representation in that soft atom type.
331+ > (lte ~m61 ~h1)
392 %.n
332 %.n
393
333
394
334
335+
395***
336***
396### `++lth`
337### `++lth`
397
338
@@ -399,20 +340,17 @@ Less-than
399
340
400Tests whether `a` is less than `b`.
341Tests whether `a` is less than `b`.
401
342
402−Accepts
343+#### Accepts
403−-------
404
344
405`a` is an atom.
345`a` is an atom.
406
346
407`b` is an atom.
347`b` is an atom.
408
348
409−Produces
349+#### Produces
410−--------
411
350
412−A flag; our version of a boolean, except that `0` is yes/true and `1` is no/false.
351+A flag.
413
352
414−Source
353+#### Source
415−------
416
354
417 ++ lth
355 ++ lth
418 ~/ %lth
356 ~/ %lth
@@ -424,9 +362,8 @@ Source
424 ?& !=(0 b)
362 ?& !=(0 b)
425 $(a (dec a), b (dec b))
363 $(a (dec a), b (dec b))
426 == == ==
364 == == ==
427− ::
365+
428−Examples
366+#### Examples
429−--------
430
367
431 > (lth 4 5)
368 > (lth 4 5)
432 %.y
369 %.y
@@ -442,17 +379,13 @@ Examples
442
379
443 > (lth 'a' 'b')
380 > (lth 'a' 'b')
444 %.y
381 %.y
445− > `@`'a' ::`a` is an atom represented as a different data type.
382+ > `@`'a'
446− 97 ::We can cast it to the aura `@` to see what its integer representation is.
383+ 97
447 > `@`'b'
384 > `@`'b'
448 98
385 98
449
386
450 > (lth 'abraham' 'bob')
387 > (lth 'abraham' 'bob')
451 %.n
388 %.n
452− > `@`'abraham'
453− > 30.787.873.400.840.801
454− > `@`'bob'
455− > 6.451.042
456
389
457
390
458***
391***
@@ -462,30 +395,26 @@ Maximum
462
395
463Computes the greater of `a` and `b`.
396Computes the greater of `a` and `b`.
464
397
465−Accepts
398+#### Accepts
466−-------
467
399
468`a` is an atom.
400`a` is an atom.
469
401
470`b` is an atom.
402`b` is an atom.
471
403
472−Produces
404+#### Produces
473−--------
474
405
475An atom.
406An atom.
476
407
477−Source
408+#### Source
478−------
479
409
480− ++ max
410+ ++ max
481 ~/ %max
411 ~/ %max
482 |= [a=@ b=@]
412 |= [a=@ b=@]
483 ^- @
413 ^- @
484 ?: (gth a b) a
414 ?: (gth a b) a
485 b
415 b
486− ::
416+
487−Examples
417+#### Examples
488−--------
489
418
490 > (max 10 100)
419 > (max 10 100)
491 100
420 100
@@ -499,16 +428,16 @@ Examples
499 > (max 'abraham' 'bob')
428 > (max 'abraham' 'bob')
500 30.787.873.400.840.801
429 30.787.873.400.840.801
501
430
502− > `@t`(max 'abraham' 'bob') ::`@t` displays the product as a `cord` (string) instead of a number.
431+ > `@t`(max 'abraham' 'bob')
503 'abraham'
432 'abraham'
504
433
505 > `@t`(max 'abraham' 'benjamin')
434 > `@t`(max 'abraham' 'benjamin')
506 'benjamin'
435 'benjamin'
507
436
508− > `@dr`(max ~m6 ~h1) ::~m61 and ~h1 are relative dates. Cast an atom to `@dr` to see its representation in that soft atom type.
437+ > `@dr`(max ~m6 ~h1)
509 ~h1
438 ~h1
510
439
511− >`@ux`(max 0xe1 0x1e) ::`0xe1` and `0x1e` are of the hexadecimal soft atom type (`@ux`).
440+ >`@ux`(max 0xe1 0x1e)
512 0xe1
441 0xe1
513
442
514***
443***
@@ -518,30 +447,26 @@ Minimum
518
447
519Computes the lesser of `a` and `b`.
448Computes the lesser of `a` and `b`.
520
449
521−Accepts
450+#### Accepts
522−-------
523
451
524`a` is an atom.
452`a` is an atom.
525
453
526`b` is an atom.
454`b` is an atom.
527
455
528−Produces
456+#### Produces
529−--------
530
457
531An atom.
458An atom.
532
459
533−Source
460+#### Source
534−------
535
461
536− ++ min
462+ ++ min
537 ~/ %min
463 ~/ %min
538 |= [a=@ b=@]
464 |= [a=@ b=@]
539 ^- @
465 ^- @
540 ?: (lth a b) a
466 ?: (lth a b) a
541 b
467 b
542− ::
468+
543−Examples
469+#### Examples
544−--------
545
470
546 > (min 10 100)
471 > (min 10 100)
547 10
472 10
@@ -555,16 +480,17 @@ Examples
555 > (min 'abraham' 'bob')
480 > (min 'abraham' 'bob')
556 6.451.042
481 6.451.042
557
482
558− > `@t`(min 'abraham' 'bob') ::`@t` causes the product to display as a `cord` instead of a number.
483+ > `@t`(min 'abraham' 'bob')
559 'bob'
484 'bob'
560
485
561 > `@t`(min 'abraham' 'benjamin')
486 > `@t`(min 'abraham' 'benjamin')
562 'abraham'
487 'abraham'
563
488
564− > `@dr`(min ~m6 ~h1) ::~m61 and ~h1 are relative dates. Cast an atom to `@dr` to see its representation in that soft atom type.
489+ > `@dr`(min ~m6 ~h1)
565 ~m6
490 ~m6
566
491
567
492
493+
568***
494***
569### `++mod`
495### `++mod`
570
496
@@ -572,30 +498,28 @@ Modulus
572
498
573Computes the remainder of dividing `a` by `b`.
499Computes the remainder of dividing `a` by `b`.
574
500
575−Accepts
501+#### Accepts
576−-------
577
502
578`a` is an atom.
503`a` is an atom.
579
504
580`b` is an atom.
505`b` is an atom.
581
506
582−Produces
507+#### Produces
583−--------
584
508
585An atom.
509An atom.
586
510
587−Source
511+#### Source
588−------
589
512
590− ++ mod
513+ ++ mod
591 ~/ %mod
514 ~/ %mod
592 |: [a=`@`1 b=`@`1]
515 |: [a=`@`1 b=`@`1]
593 ^- @
516 ^- @
594 ?< =(0 b)
517 ?< =(0 b)
595 (sub a (mul b (div a b)))
518 (sub a (mul b (div a b)))
596− ::
519+
520+
597−Examples
521+#### Examples
598−--------
522+
599
523
600 > (mod 5 2)
524 > (mod 5 2)
601 1
525 1
@@ -609,18 +533,13 @@ Examples
609 > (mod 40 20)
533 > (mod 40 20)
610 0
534 0
611
535
612− > `@`'c' ::`a` is an atom represented as a different data type.
536+ > `@`'c'
613− 99 ::We can cast it to the aura `@` to see what its integer representation is.
537+ 99
614 >`@`'a'
538 >`@`'a'
615 97
539 97
616 > (mod 'c' 'a')
540 > (mod 'c' 'a')
617 2
541 2
618
542
619− > (mod 0xe1 0x1e) ::`0xe1` and `0x1e` are of the hexadecimal soft atom type (`@ux`).
620− 15
621− > `@ux`(mod 0xe1 0x1e)
622− 0xf
623−
624
543
625***
544***
626### `++mul`
545### `++mul`
@@ -629,20 +548,17 @@ Multiply
629
548
630Multiplies `a` by `b`.
549Multiplies `a` by `b`.
631
550
632−Accepts
551+#### Accepts
633−-------
634
552
635`a` is an atom.
553`a` is an atom.
636
554
637`b` is an atom.
555`b` is an atom.
638
556
639−Produces
557+#### Produces
640−--------
641
558
642An atom.
559An atom.
643
560
644−Source
561+#### Source
645−------
646
562
647 ++ mul
563 ++ mul
648 ~/ %mul
564 ~/ %mul
@@ -652,9 +568,8 @@ Source
652 |-
568 |-
653 ?: =(0 a) c
569 ?: =(0 a) c
654 $(a (dec a), c (add b c))
570 $(a (dec a), c (add b c))
655− ::
571+
656−Examples
572+#### Examples
657−--------
658
573
659 > (mul 3 4)
574 > (mul 3 4)
660 12
575 12
@@ -662,19 +577,18 @@ Examples
662 > (mul 0 1)
577 > (mul 0 1)
663 0
578 0
664
579
665− > `@`'a' ::`a` is an atom represented as a different data type.
580+ > `@`'a'
666− 97 ::We can cast it to the aura `@` to see what its integer representation is.
581+ 97
667 > `@`'b'
582 > `@`'b'
668 98
583 98
669 > (mul 'a' 'b')
584 > (mul 'a' 'b')
670 9.506
585 9.506
671
586
672− > (mul 0x1f 0xe) ::`0x1f` and `0xe` are of the hexadecimal soft atom type (`@ux`).
673− 424
674 >`@ux`(mul 0x1f 0xe)
587 >`@ux`(mul 0x1f 0xe)
675 0x1b2
588 0x1b2
676
589
677
590
591+
678***
592***
679### `++sub`
593### `++sub`
680
594
@@ -682,31 +596,29 @@ Subtract
682
596
683Subtracts `b` from `a`.
597Subtracts `b` from `a`.
684
598
685−Accepts
599+#### Accepts
686−-------
687
600
688`a` is an atom.
601`a` is an atom.
689
602
690`b` is an atom.
603`b` is an atom.
691
604
692−Produces
605+#### Produces
693−--------
694
606
695An atom.
607An atom.
696
608
697−Source
609+#### Source
698−------
699
610
700− ++ sub
611+ ++ sub
701− ~/ %sub
612+ ~/ %sub
702− |= [a=@ b=@]
613+ |= [a=@ b=@]
703− ~| %subtract-underflow
614+ ~_ leaf+"subtract-underflow"
704− ^- @
615+ ^- @
705− ?: =(0 b) a
616+ ?: =(0 b) a
706− $(a (dec a), b (dec b))
617+ $(a (dec a), b (dec b))
707− ::
618+
619+
620+
708−Examples
621+#### Examples
709−--------
710
622
711 > (sub 10 5)
623 > (sub 10 5)
712 5
624 5
@@ -723,14 +635,14 @@ Examples
723
635
724 > (sub 'c' 'a')
636 > (sub 'c' 'a')
725 2
637 2
726− > `@`'c' ::`a` is an atom represented as a different data type.
638+ > `@`'c'
727− 99 ::We can cast it to the aura `@` to see what its integer representation is.
639+ 99
728 > `@`'a'
640 > `@`'a'
729 97
641 97
730
642
731 > (sub 0x1f 0xe)
643 > (sub 0x1f 0xe)
732 17
644 17
733− > `@ux`(sub 0x1f 0xe) ::`0xe1` and `0x1e` are of the hexadecimal soft atom type (`@ux`).
645+ > `@ux`(sub 0x1f 0xe)
734 0x11
646 0x11
735
647
736
648