@grain/stdlib 0.5.13 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/CHANGELOG.md +193 -0
  2. package/LICENSE +1 -1
  3. package/README.md +25 -2
  4. package/array.gr +1512 -199
  5. package/array.md +2032 -94
  6. package/bigint.gr +239 -140
  7. package/bigint.md +450 -106
  8. package/buffer.gr +595 -102
  9. package/buffer.md +903 -145
  10. package/bytes.gr +401 -110
  11. package/bytes.md +551 -63
  12. package/char.gr +228 -49
  13. package/char.md +373 -7
  14. package/exception.gr +26 -12
  15. package/exception.md +29 -5
  16. package/float32.gr +130 -109
  17. package/float32.md +185 -57
  18. package/float64.gr +112 -99
  19. package/float64.md +185 -57
  20. package/hash.gr +47 -37
  21. package/hash.md +21 -3
  22. package/int16.gr +430 -0
  23. package/int16.md +618 -0
  24. package/int32.gr +200 -269
  25. package/int32.md +254 -289
  26. package/int64.gr +142 -225
  27. package/int64.md +254 -289
  28. package/int8.gr +511 -0
  29. package/int8.md +786 -0
  30. package/json.gr +2084 -0
  31. package/json.md +608 -0
  32. package/list.gr +120 -68
  33. package/list.md +125 -80
  34. package/map.gr +560 -57
  35. package/map.md +672 -56
  36. package/marshal.gr +239 -227
  37. package/marshal.md +36 -4
  38. package/number.gr +626 -676
  39. package/number.md +738 -153
  40. package/option.gr +33 -35
  41. package/option.md +58 -42
  42. package/package.json +2 -2
  43. package/path.gr +148 -187
  44. package/path.md +47 -96
  45. package/pervasives.gr +75 -416
  46. package/pervasives.md +85 -180
  47. package/priorityqueue.gr +433 -74
  48. package/priorityqueue.md +422 -54
  49. package/queue.gr +362 -80
  50. package/queue.md +433 -38
  51. package/random.gr +67 -75
  52. package/random.md +68 -40
  53. package/range.gr +135 -63
  54. package/range.md +198 -43
  55. package/rational.gr +284 -0
  56. package/rational.md +545 -0
  57. package/regex.gr +933 -1066
  58. package/regex.md +59 -60
  59. package/result.gr +23 -25
  60. package/result.md +54 -39
  61. package/runtime/atof/common.gr +78 -82
  62. package/runtime/atof/common.md +22 -10
  63. package/runtime/atof/decimal.gr +102 -127
  64. package/runtime/atof/decimal.md +28 -7
  65. package/runtime/atof/lemire.gr +56 -71
  66. package/runtime/atof/lemire.md +9 -1
  67. package/runtime/atof/parse.gr +83 -110
  68. package/runtime/atof/parse.md +12 -2
  69. package/runtime/atof/slow.gr +28 -35
  70. package/runtime/atof/slow.md +9 -1
  71. package/runtime/atof/table.gr +19 -18
  72. package/runtime/atof/table.md +10 -2
  73. package/runtime/atoi/parse.gr +153 -136
  74. package/runtime/atoi/parse.md +50 -1
  75. package/runtime/bigint.gr +410 -517
  76. package/runtime/bigint.md +71 -57
  77. package/runtime/compare.gr +176 -85
  78. package/runtime/compare.md +31 -1
  79. package/runtime/dataStructures.gr +144 -32
  80. package/runtime/dataStructures.md +267 -31
  81. package/runtime/debugPrint.gr +34 -15
  82. package/runtime/debugPrint.md +37 -5
  83. package/runtime/equal.gr +53 -52
  84. package/runtime/equal.md +30 -1
  85. package/runtime/exception.gr +38 -47
  86. package/runtime/exception.md +10 -8
  87. package/runtime/gc.gr +23 -152
  88. package/runtime/gc.md +13 -17
  89. package/runtime/malloc.gr +31 -31
  90. package/runtime/malloc.md +11 -3
  91. package/runtime/numberUtils.gr +191 -172
  92. package/runtime/numberUtils.md +17 -9
  93. package/runtime/numbers.gr +1695 -1021
  94. package/runtime/numbers.md +1098 -134
  95. package/runtime/string.gr +540 -242
  96. package/runtime/string.md +76 -6
  97. package/runtime/unsafe/constants.gr +30 -13
  98. package/runtime/unsafe/constants.md +80 -0
  99. package/runtime/unsafe/conv.gr +55 -28
  100. package/runtime/unsafe/conv.md +41 -9
  101. package/runtime/unsafe/memory.gr +10 -30
  102. package/runtime/unsafe/memory.md +15 -19
  103. package/runtime/unsafe/tags.gr +37 -21
  104. package/runtime/unsafe/tags.md +88 -8
  105. package/runtime/unsafe/wasmf32.gr +30 -36
  106. package/runtime/unsafe/wasmf32.md +64 -56
  107. package/runtime/unsafe/wasmf64.gr +30 -36
  108. package/runtime/unsafe/wasmf64.md +64 -56
  109. package/runtime/unsafe/wasmi32.gr +49 -66
  110. package/runtime/unsafe/wasmi32.md +102 -94
  111. package/runtime/unsafe/wasmi64.gr +52 -79
  112. package/runtime/unsafe/wasmi64.md +108 -100
  113. package/runtime/utils/printing.gr +13 -15
  114. package/runtime/utils/printing.md +11 -3
  115. package/runtime/wasi.gr +294 -295
  116. package/runtime/wasi.md +62 -42
  117. package/set.gr +574 -64
  118. package/set.md +634 -54
  119. package/stack.gr +181 -64
  120. package/stack.md +271 -42
  121. package/string.gr +453 -533
  122. package/string.md +241 -151
  123. package/uint16.gr +369 -0
  124. package/uint16.md +585 -0
  125. package/uint32.gr +470 -0
  126. package/uint32.md +737 -0
  127. package/uint64.gr +471 -0
  128. package/uint64.md +737 -0
  129. package/uint8.gr +369 -0
  130. package/uint8.md +585 -0
  131. package/uri.gr +1093 -0
  132. package/uri.md +477 -0
  133. package/{sys → wasi}/file.gr +914 -500
  134. package/{sys → wasi}/file.md +454 -50
  135. package/wasi/process.gr +292 -0
  136. package/{sys → wasi}/process.md +164 -6
  137. package/wasi/random.gr +77 -0
  138. package/wasi/random.md +80 -0
  139. package/{sys → wasi}/time.gr +15 -22
  140. package/{sys → wasi}/time.md +5 -5
  141. package/immutablearray.gr +0 -929
  142. package/immutablearray.md +0 -1038
  143. package/immutablemap.gr +0 -493
  144. package/immutablemap.md +0 -479
  145. package/immutablepriorityqueue.gr +0 -360
  146. package/immutablepriorityqueue.md +0 -291
  147. package/immutableset.gr +0 -498
  148. package/immutableset.md +0 -449
  149. package/runtime/debug.gr +0 -2
  150. package/runtime/debug.md +0 -6
  151. package/runtime/unsafe/errors.gr +0 -36
  152. package/runtime/unsafe/errors.md +0 -204
  153. package/sys/process.gr +0 -254
  154. package/sys/random.gr +0 -79
  155. package/sys/random.md +0 -66
package/bigint.md CHANGED
@@ -10,12 +10,24 @@ No other changes yet.
10
10
  </details>
11
11
 
12
12
  ```grain
13
- import BigInt from "bigint"
13
+ from "bigint" include Bigint
14
14
  ```
15
15
 
16
- ## Conversions
16
+ ```grain
17
+ 9223372036854775809t
18
+ ```
19
+
20
+ ```grain
21
+ 0t
22
+ ```
23
+
24
+ ```grain
25
+ -9223372036854775809t
26
+ ```
27
+
28
+ ## Values
17
29
 
18
- Functions for converting between Numbers and the BigInt type.
30
+ Functions and constants included in the BigInt module.
19
31
 
20
32
  ### BigInt.**fromNumber**
21
33
 
@@ -25,7 +37,7 @@ No other changes yet.
25
37
  </details>
26
38
 
27
39
  ```grain
28
- fromNumber : Number -> BigInt
40
+ fromNumber : (number: Number) => BigInt
29
41
  ```
30
42
 
31
43
  Converts a Number to a BigInt.
@@ -50,7 +62,7 @@ No other changes yet.
50
62
  </details>
51
63
 
52
64
  ```grain
53
- toNumber : BigInt -> Number
65
+ toNumber : (num: BigInt) => Number
54
66
  ```
55
67
 
56
68
  Converts a BigInt to a Number.
@@ -67,10 +79,6 @@ Returns:
67
79
  |----|-----------|
68
80
  |`Number`|The BigInt represented as a Number|
69
81
 
70
- ## Operations
71
-
72
- Mathematical operations for BigInt values.
73
-
74
82
  ### BigInt.**incr**
75
83
 
76
84
  <details disabled>
@@ -79,7 +87,7 @@ No other changes yet.
79
87
  </details>
80
88
 
81
89
  ```grain
82
- incr : BigInt -> BigInt
90
+ incr : (num: BigInt) => BigInt
83
91
  ```
84
92
 
85
93
  Increments the value by one.
@@ -96,6 +104,16 @@ Returns:
96
104
  |----|-----------|
97
105
  |`BigInt`|The incremented value|
98
106
 
107
+ Examples:
108
+
109
+ ```grain
110
+ BigInt.incr(1t) == 2t
111
+ ```
112
+
113
+ ```grain
114
+ BigInt.incr(-2t) == -1t
115
+ ```
116
+
99
117
  ### BigInt.**decr**
100
118
 
101
119
  <details disabled>
@@ -104,7 +122,7 @@ No other changes yet.
104
122
  </details>
105
123
 
106
124
  ```grain
107
- decr : BigInt -> BigInt
125
+ decr : (num: BigInt) => BigInt
108
126
  ```
109
127
 
110
128
  Decrements the value by one.
@@ -121,6 +139,16 @@ Returns:
121
139
  |----|-----------|
122
140
  |`BigInt`|The decremented value|
123
141
 
142
+ Examples:
143
+
144
+ ```grain
145
+ BigInt.decr(2t) == 1t
146
+ ```
147
+
148
+ ```grain
149
+ BigInt.decr(-2t) == -3t
150
+ ```
151
+
124
152
  ### BigInt.**neg**
125
153
 
126
154
  <details disabled>
@@ -129,7 +157,7 @@ No other changes yet.
129
157
  </details>
130
158
 
131
159
  ```grain
132
- neg : BigInt -> BigInt
160
+ neg : (num: BigInt) => BigInt
133
161
  ```
134
162
 
135
163
  Negates the given operand.
@@ -146,6 +174,16 @@ Returns:
146
174
  |----|-----------|
147
175
  |`BigInt`|The negated operand|
148
176
 
177
+ Examples:
178
+
179
+ ```grain
180
+ BigInt.neg(1t) == -1t
181
+ ```
182
+
183
+ ```grain
184
+ BigInt.neg(-1t) == 1t
185
+ ```
186
+
149
187
  ### BigInt.**abs**
150
188
 
151
189
  <details disabled>
@@ -154,7 +192,7 @@ No other changes yet.
154
192
  </details>
155
193
 
156
194
  ```grain
157
- abs : BigInt -> BigInt
195
+ abs : (num: BigInt) => BigInt
158
196
  ```
159
197
 
160
198
  Returns the absolute value of the given operand.
@@ -171,15 +209,32 @@ Returns:
171
209
  |----|-----------|
172
210
  |`BigInt`|The operand's absolute value|
173
211
 
174
- ### BigInt.**add**
212
+ Examples:
175
213
 
176
- <details disabled>
177
- <summary tabindex="-1">Added in <code>0.5.0</code></summary>
178
- No other changes yet.
214
+ ```grain
215
+ BigInt.abs(1t) == 1t
216
+ ```
217
+
218
+ ```grain
219
+ BigInt.abs(-1t) == 1t
220
+ ```
221
+
222
+ ### BigInt.**(+)**
223
+
224
+ <details>
225
+ <summary>Added in <code>0.6.0</code></summary>
226
+ <table>
227
+ <thead>
228
+ <tr><th>version</th><th>changes</th></tr>
229
+ </thead>
230
+ <tbody>
231
+ <tr><td><code>0.5.0</code></td><td>Originally named `add`</td></tr>
232
+ </tbody>
233
+ </table>
179
234
  </details>
180
235
 
181
236
  ```grain
182
- add : (BigInt, BigInt) -> BigInt
237
+ (+) : (num1: BigInt, num2: BigInt) => BigInt
183
238
  ```
184
239
 
185
240
  Computes the sum of its operands.
@@ -197,15 +252,29 @@ Returns:
197
252
  |----|-----------|
198
253
  |`BigInt`|The sum of the two operands|
199
254
 
200
- ### BigInt.**sub**
255
+ Examples:
201
256
 
202
- <details disabled>
203
- <summary tabindex="-1">Added in <code>0.5.0</code></summary>
204
- No other changes yet.
257
+ ```grain
258
+ use BigInt.{ (+) }
259
+ assert 1t + 1t == 2t
260
+ ```
261
+
262
+ ### BigInt.**(-)**
263
+
264
+ <details>
265
+ <summary>Added in <code>0.6.0</code></summary>
266
+ <table>
267
+ <thead>
268
+ <tr><th>version</th><th>changes</th></tr>
269
+ </thead>
270
+ <tbody>
271
+ <tr><td><code>0.5.0</code></td><td>Originally named `sub`</td></tr>
272
+ </tbody>
273
+ </table>
205
274
  </details>
206
275
 
207
276
  ```grain
208
- sub : (BigInt, BigInt) -> BigInt
277
+ (-) : (num1: BigInt, num2: BigInt) => BigInt
209
278
  ```
210
279
 
211
280
  Computes the difference of its operands.
@@ -223,15 +292,29 @@ Returns:
223
292
  |----|-----------|
224
293
  |`BigInt`|The difference of the two operands|
225
294
 
226
- ### BigInt.**mul**
295
+ Examples:
227
296
 
228
- <details disabled>
229
- <summary tabindex="-1">Added in <code>0.5.0</code></summary>
230
- No other changes yet.
297
+ ```grain
298
+ use BigInt.{ (-) }
299
+ assert 3t - 1t == 2t
300
+ ```
301
+
302
+ ### BigInt.**(*)**
303
+
304
+ <details>
305
+ <summary>Added in <code>0.6.0</code></summary>
306
+ <table>
307
+ <thead>
308
+ <tr><th>version</th><th>changes</th></tr>
309
+ </thead>
310
+ <tbody>
311
+ <tr><td><code>0.5.0</code></td><td>Originally named `mul`</td></tr>
312
+ </tbody>
313
+ </table>
231
314
  </details>
232
315
 
233
316
  ```grain
234
- mul : (BigInt, BigInt) -> BigInt
317
+ (*) : (num1: BigInt, num2: BigInt) => BigInt
235
318
  ```
236
319
 
237
320
  Computes the product of its operands.
@@ -249,15 +332,29 @@ Returns:
249
332
  |----|-----------|
250
333
  |`BigInt`|The product of the two operands|
251
334
 
252
- ### BigInt.**div**
335
+ Examples:
253
336
 
254
- <details disabled>
255
- <summary tabindex="-1">Added in <code>0.5.0</code></summary>
256
- No other changes yet.
337
+ ```grain
338
+ use BigInt.{ (*) }
339
+ assert 3t * 3t == 9t
340
+ ```
341
+
342
+ ### BigInt.**(/)**
343
+
344
+ <details>
345
+ <summary>Added in <code>0.6.0</code></summary>
346
+ <table>
347
+ <thead>
348
+ <tr><th>version</th><th>changes</th></tr>
349
+ </thead>
350
+ <tbody>
351
+ <tr><td><code>0.5.0</code></td><td>Originally named `div`</td></tr>
352
+ </tbody>
353
+ </table>
257
354
  </details>
258
355
 
259
356
  ```grain
260
- div : (BigInt, BigInt) -> BigInt
357
+ (/) : (num1: BigInt, num2: BigInt) => BigInt
261
358
  ```
262
359
 
263
360
  Computes the quotient of its operands using signed (truncated) division
@@ -276,6 +373,13 @@ Returns:
276
373
  |----|-----------|
277
374
  |`BigInt`|The quotient of its operands|
278
375
 
376
+ Examples:
377
+
378
+ ```grain
379
+ use BigInt.{ (/) }
380
+ assert 9t / 3t == 3t
381
+ ```
382
+
279
383
  ### BigInt.**rem**
280
384
 
281
385
  <details disabled>
@@ -284,7 +388,7 @@ No other changes yet.
284
388
  </details>
285
389
 
286
390
  ```grain
287
- rem : (BigInt, BigInt) -> BigInt
391
+ rem : (num1: BigInt, num2: BigInt) => BigInt
288
392
  ```
289
393
 
290
394
  Computes the remainder of the division of its operands using signed (truncated) division
@@ -303,6 +407,12 @@ Returns:
303
407
  |----|-----------|
304
408
  |`BigInt`|The remainder of its operands|
305
409
 
410
+ Examples:
411
+
412
+ ```grain
413
+ BigInt.rem(3t, 2t) == 1t
414
+ ```
415
+
306
416
  ### BigInt.**quotRem**
307
417
 
308
418
  <details disabled>
@@ -311,7 +421,7 @@ No other changes yet.
311
421
  </details>
312
422
 
313
423
  ```grain
314
- quotRem : (BigInt, BigInt) -> (BigInt, BigInt)
424
+ quotRem : (num1: BigInt, num2: BigInt) => (BigInt, BigInt)
315
425
  ```
316
426
 
317
427
  Computes the quotient and remainder of its operands using signed (truncated) division.
@@ -329,6 +439,12 @@ Returns:
329
439
  |----|-----------|
330
440
  |`(BigInt, BigInt)`|The quotient and remainder of its operands|
331
441
 
442
+ Examples:
443
+
444
+ ```grain
445
+ BigInt.quotRem(7t, 2t) == (3t, 1t))
446
+ ```
447
+
332
448
  ### BigInt.**gcd**
333
449
 
334
450
  <details disabled>
@@ -337,7 +453,7 @@ No other changes yet.
337
453
  </details>
338
454
 
339
455
  ```grain
340
- gcd : (BigInt, BigInt) -> BigInt
456
+ gcd : (num1: BigInt, num2: BigInt) => BigInt
341
457
  ```
342
458
 
343
459
  Computes the greatest common divisior of the two operands.
@@ -355,19 +471,28 @@ Returns:
355
471
  |----|-----------|
356
472
  |`BigInt`|The greatest common divisor of its operands|
357
473
 
358
- ## Bitwise operations
359
-
360
- Functions for operating on bits of BigInt values.
474
+ Examples:
361
475
 
362
- ### BigInt.**shl**
476
+ ```grain
477
+ BigInt.gcd(36t, 24t) == 12t
478
+ ```
363
479
 
364
- <details disabled>
365
- <summary tabindex="-1">Added in <code>0.5.0</code></summary>
366
- No other changes yet.
480
+ ### BigInt.**(<<)**
481
+
482
+ <details>
483
+ <summary>Added in <code>0.6.0</code></summary>
484
+ <table>
485
+ <thead>
486
+ <tr><th>version</th><th>changes</th></tr>
487
+ </thead>
488
+ <tbody>
489
+ <tr><td><code>0.5.0</code></td><td>Originally named `shl`</td></tr>
490
+ </tbody>
491
+ </table>
367
492
  </details>
368
493
 
369
494
  ```grain
370
- shl : (BigInt, Int32) -> BigInt
495
+ (<<) : (num: BigInt, places: Int32) => BigInt
371
496
  ```
372
497
 
373
498
  Shifts the bits of the value left by the given number of bits.
@@ -385,15 +510,29 @@ Returns:
385
510
  |----|-----------|
386
511
  |`BigInt`|The shifted value|
387
512
 
388
- ### BigInt.**shr**
513
+ Examples:
389
514
 
390
- <details disabled>
391
- <summary tabindex="-1">Added in <code>0.5.0</code></summary>
392
- No other changes yet.
515
+ ```grain
516
+ use BigInt.{ (<<) }
517
+ assert (10t << 2l) == 40t
518
+ ```
519
+
520
+ ### BigInt.**(>>)**
521
+
522
+ <details>
523
+ <summary>Added in <code>0.6.0</code></summary>
524
+ <table>
525
+ <thead>
526
+ <tr><th>version</th><th>changes</th></tr>
527
+ </thead>
528
+ <tbody>
529
+ <tr><td><code>0.5.0</code></td><td>Originally named `shr`</td></tr>
530
+ </tbody>
531
+ </table>
393
532
  </details>
394
533
 
395
534
  ```grain
396
- shr : (BigInt, Int32) -> BigInt
535
+ (>>) : (num: BigInt, places: Int32) => BigInt
397
536
  ```
398
537
 
399
538
  Shifts the bits of the value right by the given number of bits, preserving the sign bit.
@@ -411,9 +550,12 @@ Returns:
411
550
  |----|-----------|
412
551
  |`BigInt`|The shifted value|
413
552
 
414
- ## Comparisons
553
+ Examples:
415
554
 
416
- Functions for comparing BigInt values.
555
+ ```grain
556
+ use BigInt.{ (>>) }
557
+ assert (9999t >> 2l) == 2499t
558
+ ```
417
559
 
418
560
  ### BigInt.**eqz**
419
561
 
@@ -423,7 +565,7 @@ No other changes yet.
423
565
  </details>
424
566
 
425
567
  ```grain
426
- eqz : BigInt -> Bool
568
+ eqz : (num: BigInt) => Bool
427
569
  ```
428
570
 
429
571
  Checks if the given value is equal to zero.
@@ -440,15 +582,32 @@ Returns:
440
582
  |----|-----------|
441
583
  |`Bool`|`true` if the first value is equal to zero or `false` otherwise|
442
584
 
443
- ### BigInt.**eq**
585
+ Examples:
444
586
 
445
- <details disabled>
446
- <summary tabindex="-1">Added in <code>0.5.0</code></summary>
447
- No other changes yet.
587
+ ```grain
588
+ assert BigInt.eqz(0t) == true
589
+ ```
590
+
591
+ ```grain
592
+ assert BigInt.eqz(1t) == false
593
+ ```
594
+
595
+ ### BigInt.**(==)**
596
+
597
+ <details>
598
+ <summary>Added in <code>0.6.0</code></summary>
599
+ <table>
600
+ <thead>
601
+ <tr><th>version</th><th>changes</th></tr>
602
+ </thead>
603
+ <tbody>
604
+ <tr><td><code>0.5.0</code></td><td>Originally named `eq`</td></tr>
605
+ </tbody>
606
+ </table>
448
607
  </details>
449
608
 
450
609
  ```grain
451
- eq : (BigInt, BigInt) -> Bool
610
+ (==) : (num1: BigInt, num2: BigInt) => Bool
452
611
  ```
453
612
 
454
613
  Checks if the first value is equal to the second value.
@@ -466,15 +625,34 @@ Returns:
466
625
  |----|-----------|
467
626
  |`Bool`|`true` if the first value is equal to the second value or `false` otherwise|
468
627
 
469
- ### BigInt.**ne**
628
+ Examples:
470
629
 
471
- <details disabled>
472
- <summary tabindex="-1">Added in <code>0.5.0</code></summary>
473
- No other changes yet.
630
+ ```grain
631
+ use BigInt.{ (==) }
632
+ assert 1t == 1t
633
+ ```
634
+
635
+ ```grain
636
+ use BigInt.{ (==) }
637
+ assert -10t == -10t
638
+ ```
639
+
640
+ ### BigInt.**(!=)**
641
+
642
+ <details>
643
+ <summary>Added in <code>0.6.0</code></summary>
644
+ <table>
645
+ <thead>
646
+ <tr><th>version</th><th>changes</th></tr>
647
+ </thead>
648
+ <tbody>
649
+ <tr><td><code>0.5.0</code></td><td>Originally named `ne`</td></tr>
650
+ </tbody>
651
+ </table>
474
652
  </details>
475
653
 
476
654
  ```grain
477
- ne : (BigInt, BigInt) -> Bool
655
+ (!=) : (num1: BigInt, num2: BigInt) => Bool
478
656
  ```
479
657
 
480
658
  Checks if the first value is not equal to the second value.
@@ -492,15 +670,34 @@ Returns:
492
670
  |----|-----------|
493
671
  |`Bool`|`true` if the first value is not equal to the second value or `false` otherwise|
494
672
 
495
- ### BigInt.**lt**
673
+ Examples:
496
674
 
497
- <details disabled>
498
- <summary tabindex="-1">Added in <code>0.5.0</code></summary>
499
- No other changes yet.
675
+ ```grain
676
+ use BigInt.{ (!=) }
677
+ assert 1t != 2t
678
+ ```
679
+
680
+ ```grain
681
+ use BigInt.{ (!=) }
682
+ assert -10t != -20t
683
+ ```
684
+
685
+ ### BigInt.**(<)**
686
+
687
+ <details>
688
+ <summary>Added in <code>0.6.0</code></summary>
689
+ <table>
690
+ <thead>
691
+ <tr><th>version</th><th>changes</th></tr>
692
+ </thead>
693
+ <tbody>
694
+ <tr><td><code>0.5.0</code></td><td>Originally named `lt`</td></tr>
695
+ </tbody>
696
+ </table>
500
697
  </details>
501
698
 
502
699
  ```grain
503
- lt : (BigInt, BigInt) -> Bool
700
+ (<) : (num1: BigInt, num2: BigInt) => Bool
504
701
  ```
505
702
 
506
703
  Checks if the first value is less than the second value.
@@ -518,15 +715,34 @@ Returns:
518
715
  |----|-----------|
519
716
  |`Bool`|`true` if the first value is less than the second value or `false` otherwise|
520
717
 
521
- ### BigInt.**lte**
718
+ Examples:
522
719
 
523
- <details disabled>
524
- <summary tabindex="-1">Added in <code>0.5.0</code></summary>
525
- No other changes yet.
720
+ ```grain
721
+ use BigInt.{ (<) }
722
+ assert 1t < 2t
723
+ ```
724
+
725
+ ```grain
726
+ use BigInt.{ (<) }
727
+ assert -10t < 0t
728
+ ```
729
+
730
+ ### BigInt.**(<=)**
731
+
732
+ <details>
733
+ <summary>Added in <code>0.6.0</code></summary>
734
+ <table>
735
+ <thead>
736
+ <tr><th>version</th><th>changes</th></tr>
737
+ </thead>
738
+ <tbody>
739
+ <tr><td><code>0.5.0</code></td><td>Originally named `lte`</td></tr>
740
+ </tbody>
741
+ </table>
526
742
  </details>
527
743
 
528
744
  ```grain
529
- lte : (BigInt, BigInt) -> Bool
745
+ (<=) : (num1: BigInt, num2: BigInt) => Bool
530
746
  ```
531
747
 
532
748
  Checks if the first value is less than or equal to the second value.
@@ -544,15 +760,39 @@ Returns:
544
760
  |----|-----------|
545
761
  |`Bool`|`true` if the first value is less than or equal to the second value or `false` otherwise|
546
762
 
547
- ### BigInt.**gt**
763
+ Examples:
548
764
 
549
- <details disabled>
550
- <summary tabindex="-1">Added in <code>0.5.0</code></summary>
551
- No other changes yet.
765
+ ```grain
766
+ use BigInt.{ (<=) }
767
+ assert 1t <= 1t
768
+ ```
769
+
770
+ ```grain
771
+ use BigInt.{ (<=) }
772
+ assert -10t <= 0t
773
+ ```
774
+
775
+ ```grain
776
+ use BigInt.{ (<=) }
777
+ assert 2t <= 3t
778
+ ```
779
+
780
+ ### BigInt.**(>)**
781
+
782
+ <details>
783
+ <summary>Added in <code>0.6.0</code></summary>
784
+ <table>
785
+ <thead>
786
+ <tr><th>version</th><th>changes</th></tr>
787
+ </thead>
788
+ <tbody>
789
+ <tr><td><code>0.5.0</code></td><td>Originally named `gt`</td></tr>
790
+ </tbody>
791
+ </table>
552
792
  </details>
553
793
 
554
794
  ```grain
555
- gt : (BigInt, BigInt) -> Bool
795
+ (>) : (num1: BigInt, num2: BigInt) => Bool
556
796
  ```
557
797
 
558
798
  Checks if the first value is greater than the second value.
@@ -570,15 +810,34 @@ Returns:
570
810
  |----|-----------|
571
811
  |`Bool`|`true` if the first value is greater than the second value or `false` otherwise|
572
812
 
573
- ### BigInt.**gte**
813
+ Examples:
574
814
 
575
- <details disabled>
576
- <summary tabindex="-1">Added in <code>0.5.0</code></summary>
577
- No other changes yet.
815
+ ```grain
816
+ use BigInt.{ (>) }
817
+ assert 2t > 1t
818
+ ```
819
+
820
+ ```grain
821
+ use BigInt.{ (>) }
822
+ assert 0t > -10t
823
+ ```
824
+
825
+ ### BigInt.**(>=)**
826
+
827
+ <details>
828
+ <summary>Added in <code>0.6.0</code></summary>
829
+ <table>
830
+ <thead>
831
+ <tr><th>version</th><th>changes</th></tr>
832
+ </thead>
833
+ <tbody>
834
+ <tr><td><code>0.5.0</code></td><td>Originally named `gte`</td></tr>
835
+ </tbody>
836
+ </table>
578
837
  </details>
579
838
 
580
839
  ```grain
581
- gte : (BigInt, BigInt) -> Bool
840
+ (>=) : (num1: BigInt, num2: BigInt) => Bool
582
841
  ```
583
842
 
584
843
  Checks if the first value is greater than or equal to the second value.
@@ -596,9 +855,22 @@ Returns:
596
855
  |----|-----------|
597
856
  |`Bool`|`true` if the first value is greater than or equal to the second value or `false` otherwise|
598
857
 
599
- ## Bitwise logic
858
+ Examples:
600
859
 
601
- Boolean operations on the bits of BigInt values.
860
+ ```grain
861
+ use BigInt.{ (>=) }
862
+ assert 1t >= 1t
863
+ ```
864
+
865
+ ```grain
866
+ use BigInt.{ (>=) }
867
+ assert 0t >= -10t
868
+ ```
869
+
870
+ ```grain
871
+ use BigInt.{ (>=) }
872
+ assert 3t >= 2t
873
+ ```
602
874
 
603
875
  ### BigInt.**lnot**
604
876
 
@@ -608,7 +880,7 @@ No other changes yet.
608
880
  </details>
609
881
 
610
882
  ```grain
611
- lnot : BigInt -> BigInt
883
+ lnot : (num: BigInt) => BigInt
612
884
  ```
613
885
 
614
886
  Computes the bitwise NOT of the given value.
@@ -625,15 +897,28 @@ Returns:
625
897
  |----|-----------|
626
898
  |`BigInt`|Containing the inverted bits of the given value|
627
899
 
628
- ### BigInt.**land**
900
+ Examples:
629
901
 
630
- <details disabled>
631
- <summary tabindex="-1">Added in <code>0.5.0</code></summary>
632
- No other changes yet.
902
+ ```grain
903
+ BigInt.lnot(91234t) == -91235t
904
+ ```
905
+
906
+ ### BigInt.**(&)**
907
+
908
+ <details>
909
+ <summary>Added in <code>0.6.0</code></summary>
910
+ <table>
911
+ <thead>
912
+ <tr><th>version</th><th>changes</th></tr>
913
+ </thead>
914
+ <tbody>
915
+ <tr><td><code>0.5.0</code></td><td>Originally named `land`</td></tr>
916
+ </tbody>
917
+ </table>
633
918
  </details>
634
919
 
635
920
  ```grain
636
- land : (BigInt, BigInt) -> BigInt
921
+ (&) : (num1: BigInt, num2: BigInt) => BigInt
637
922
  ```
638
923
 
639
924
  Computes the bitwise AND (`&`) on the given operands.
@@ -651,15 +936,29 @@ Returns:
651
936
  |----|-----------|
652
937
  |`BigInt`|Containing a `1` in each bit position for which the corresponding bits of both operands are `1`|
653
938
 
654
- ### BigInt.**lor**
939
+ Examples:
655
940
 
656
- <details disabled>
657
- <summary tabindex="-1">Added in <code>0.5.0</code></summary>
658
- No other changes yet.
941
+ ```grain
942
+ use BigInt.{ (&) }
943
+ assert (4t & 3t) == 0t
944
+ ```
945
+
946
+ ### BigInt.**(|)**
947
+
948
+ <details>
949
+ <summary>Added in <code>0.6.0</code></summary>
950
+ <table>
951
+ <thead>
952
+ <tr><th>version</th><th>changes</th></tr>
953
+ </thead>
954
+ <tbody>
955
+ <tr><td><code>0.5.0</code></td><td>Originally named `lor`</td></tr>
956
+ </tbody>
957
+ </table>
659
958
  </details>
660
959
 
661
960
  ```grain
662
- lor : (BigInt, BigInt) -> BigInt
961
+ (|) : (num1: BigInt, num2: BigInt) => BigInt
663
962
  ```
664
963
 
665
964
  Computes the bitwise OR (`|`) on the given operands.
@@ -677,15 +976,29 @@ Returns:
677
976
  |----|-----------|
678
977
  |`BigInt`|Containing a `1` in each bit position for which the corresponding bits of either or both operands are `1`|
679
978
 
680
- ### BigInt.**lxor**
979
+ Examples:
681
980
 
682
- <details disabled>
683
- <summary tabindex="-1">Added in <code>0.5.0</code></summary>
684
- No other changes yet.
981
+ ```grain
982
+ use BigInt.{ (|) }
983
+ assert (5t | 3t) == 7t
984
+ ```
985
+
986
+ ### BigInt.**(^)**
987
+
988
+ <details>
989
+ <summary>Added in <code>0.6.0</code></summary>
990
+ <table>
991
+ <thead>
992
+ <tr><th>version</th><th>changes</th></tr>
993
+ </thead>
994
+ <tbody>
995
+ <tr><td><code>0.5.0</code></td><td>Originally named `lxor`</td></tr>
996
+ </tbody>
997
+ </table>
685
998
  </details>
686
999
 
687
1000
  ```grain
688
- lxor : (BigInt, BigInt) -> BigInt
1001
+ (^) : (num1: BigInt, num2: BigInt) => BigInt
689
1002
  ```
690
1003
 
691
1004
  Computes the bitwise XOR (`^`) on the given operands.
@@ -703,6 +1016,13 @@ Returns:
703
1016
  |----|-----------|
704
1017
  |`BigInt`|Containing a `1` in each bit position for which the corresponding bits of either but not both operands are `1`|
705
1018
 
1019
+ Examples:
1020
+
1021
+ ```grain
1022
+ use BigInt.{ (^) }
1023
+ assert (5t ^ 3t) == 6t
1024
+ ```
1025
+
706
1026
  ### BigInt.**clz**
707
1027
 
708
1028
  <details disabled>
@@ -711,7 +1031,7 @@ No other changes yet.
711
1031
  </details>
712
1032
 
713
1033
  ```grain
714
- clz : BigInt -> Int32
1034
+ clz : (num: BigInt) => Int32
715
1035
  ```
716
1036
 
717
1037
  Counts the number of leading zero bits in the value.
@@ -729,6 +1049,12 @@ Returns:
729
1049
  |----|-----------|
730
1050
  |`Int32`|The amount of leading zeros|
731
1051
 
1052
+ Examples:
1053
+
1054
+ ```grain
1055
+ BigInt.clz(5t) == 2147483647t
1056
+ ```
1057
+
732
1058
  ### BigInt.**ctz**
733
1059
 
734
1060
  <details disabled>
@@ -737,7 +1063,7 @@ No other changes yet.
737
1063
  </details>
738
1064
 
739
1065
  ```grain
740
- ctz : BigInt -> Int64
1066
+ ctz : (num: BigInt) => Int64
741
1067
  ```
742
1068
 
743
1069
  Counts the number of trailing zero bits in the value.
@@ -754,6 +1080,12 @@ Returns:
754
1080
  |----|-----------|
755
1081
  |`Int64`|The amount of trailing zeros|
756
1082
 
1083
+ Examples:
1084
+
1085
+ ```grain
1086
+ BigInt.ctz(14t) == 1t
1087
+ ```
1088
+
757
1089
  ### BigInt.**popcnt**
758
1090
 
759
1091
  <details disabled>
@@ -762,7 +1094,7 @@ No other changes yet.
762
1094
  </details>
763
1095
 
764
1096
  ```grain
765
- popcnt : BigInt -> Option<Int64>
1097
+ popcnt : (num: BigInt) => Option<Int64>
766
1098
  ```
767
1099
 
768
1100
  Counts the number of bits set to `1` in the value, also known as a population count.
@@ -780,9 +1112,11 @@ Returns:
780
1112
  |----|-----------|
781
1113
  |`Option<Int64>`|The amount of 1-bits in its operand|
782
1114
 
783
- ## Other
1115
+ Examples:
784
1116
 
785
- Other functions on BigInts.
1117
+ ```grain
1118
+ BigInt.popcnt(14t) == 1t
1119
+ ```
786
1120
 
787
1121
  ### BigInt.**toString**
788
1122
 
@@ -792,7 +1126,7 @@ No other changes yet.
792
1126
  </details>
793
1127
 
794
1128
  ```grain
795
- toString : BigInt -> String
1129
+ toString : (num: BigInt) => String
796
1130
  ```
797
1131
 
798
1132
  Converts the given operand to a string.
@@ -809,3 +1143,13 @@ Returns:
809
1143
  |----|-----------|
810
1144
  |`String`|The operand, as a string|
811
1145
 
1146
+ Examples:
1147
+
1148
+ ```grain
1149
+ BigInt.toString(1t) == "1"
1150
+ ```
1151
+
1152
+ ```grain
1153
+ BigInt.toString(-1t) == "-1"
1154
+ ```
1155
+