@grain/stdlib 0.7.0 → 0.7.2
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.
- package/CHANGELOG.md +18 -0
- package/array.md +491 -491
- package/bigint.md +198 -198
- package/buffer.gr +66 -1
- package/buffer.md +395 -272
- package/bytes.gr +1 -0
- package/bytes.md +200 -199
- package/char.md +125 -125
- package/exception.md +9 -9
- package/float32.md +195 -195
- package/float64.md +195 -195
- package/fs.md +115 -115
- package/hash.md +16 -16
- package/int16.md +155 -155
- package/int32.gr +1 -1
- package/int32.md +207 -207
- package/int64.gr +1 -1
- package/int64.md +207 -207
- package/int8.md +155 -155
- package/json.md +59 -59
- package/list.md +347 -347
- package/map.md +222 -222
- package/marshal.md +12 -12
- package/number.gr +119 -5
- package/number.md +503 -261
- package/option.md +141 -141
- package/package.json +2 -2
- package/path.gr +82 -65
- package/path.md +210 -141
- package/pervasives.md +238 -238
- package/priorityqueue.md +112 -112
- package/queue.md +117 -117
- package/random.md +37 -37
- package/range.md +36 -36
- package/rational.md +107 -107
- package/regex.md +91 -91
- package/result.md +102 -102
- package/runtime/atof/decimal.md +6 -6
- package/runtime/compare.md +7 -7
- package/runtime/dataStructures.md +178 -178
- package/runtime/equal.md +7 -7
- package/runtime/exception.md +15 -15
- package/runtime/malloc.md +9 -9
- package/runtime/numbers.md +269 -269
- package/runtime/string.md +17 -17
- package/runtime/unsafe/conv.md +6 -6
- package/runtime/unsafe/memory.gr +2 -19
- package/runtime/unsafe/memory.md +10 -10
- package/runtime/utf8.md +31 -31
- package/runtime/wasi.md +9 -9
- package/set.md +211 -211
- package/stack.md +122 -122
- package/string.md +228 -228
- package/uint16.md +148 -148
- package/uint32.md +192 -192
- package/uint64.md +192 -192
- package/uint8.md +148 -148
- package/uri.md +77 -77
- package/wasi/file.md +269 -269
- package/wasi/process.md +21 -21
- package/wasi/random.md +9 -9
- package/wasi/time.md +12 -12
package/range.md
CHANGED
|
@@ -51,16 +51,16 @@ Checks if the given number is within the range.
|
|
|
51
51
|
|
|
52
52
|
Parameters:
|
|
53
53
|
|
|
54
|
-
|param|type|description|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
| param | type | description |
|
|
55
|
+
| ------- | --------------- | ------------------------- |
|
|
56
|
+
| `value` | `Number` | The number being checked |
|
|
57
|
+
| `range` | `Range<Number>` | The range to check within |
|
|
58
58
|
|
|
59
59
|
Returns:
|
|
60
60
|
|
|
61
|
-
|type|description|
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
| type | description |
|
|
62
|
+
| ------ | ---------------------------------------- |
|
|
63
|
+
| `Bool` | Whether or not the value is within range |
|
|
64
64
|
|
|
65
65
|
Examples:
|
|
66
66
|
|
|
@@ -98,10 +98,10 @@ always changed by `1`, even if non-integer values were provided in the range.
|
|
|
98
98
|
|
|
99
99
|
Parameters:
|
|
100
100
|
|
|
101
|
-
|param|type|description|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
| param | type | description |
|
|
102
|
+
| ------- | ---------------- | ------------------------------------------------------- |
|
|
103
|
+
| `fn` | `Number => Void` | The function to be executed on each number in the range |
|
|
104
|
+
| `range` | `Range<Number>` | The range to iterate |
|
|
105
105
|
|
|
106
106
|
Examples:
|
|
107
107
|
|
|
@@ -135,16 +135,16 @@ always changed by `1`, even if non-integer values were provided in the range.
|
|
|
135
135
|
|
|
136
136
|
Parameters:
|
|
137
137
|
|
|
138
|
-
|param|type|description|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
| param | type | description |
|
|
139
|
+
| ------- | --------------- | ------------------------------------------------------------------------------------------ |
|
|
140
|
+
| `fn` | `Number => a` | The function called on each number in the range that returns the value for the output list |
|
|
141
|
+
| `range` | `Range<Number>` | The range to iterate |
|
|
142
142
|
|
|
143
143
|
Returns:
|
|
144
144
|
|
|
145
|
-
|type|description|
|
|
146
|
-
|
|
147
|
-
|
|
145
|
+
| type | description |
|
|
146
|
+
| --------- | --------------------------------------------------- |
|
|
147
|
+
| `List<a>` | A list containing all values returned from the `fn` |
|
|
148
148
|
|
|
149
149
|
Examples:
|
|
150
150
|
|
|
@@ -180,16 +180,16 @@ Checks if the given number is within the range.
|
|
|
180
180
|
|
|
181
181
|
Parameters:
|
|
182
182
|
|
|
183
|
-
|param|type|description|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
183
|
+
| param | type | description |
|
|
184
|
+
| ------- | --------------- | ------------------------- |
|
|
185
|
+
| `value` | `Number` | The number being checked |
|
|
186
|
+
| `range` | `Range<Number>` | The range to check within |
|
|
187
187
|
|
|
188
188
|
Returns:
|
|
189
189
|
|
|
190
|
-
|type|description|
|
|
191
|
-
|
|
192
|
-
|
|
190
|
+
| type | description |
|
|
191
|
+
| ------ | ---------------------------------------- |
|
|
192
|
+
| `Bool` | Whether or not the value is within range |
|
|
193
193
|
|
|
194
194
|
Examples:
|
|
195
195
|
|
|
@@ -227,10 +227,10 @@ always changed by `1`, even if non-integer values were provided in the range.
|
|
|
227
227
|
|
|
228
228
|
Parameters:
|
|
229
229
|
|
|
230
|
-
|param|type|description|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
230
|
+
| param | type | description |
|
|
231
|
+
| ------- | ---------------- | ------------------------------------------------------- |
|
|
232
|
+
| `fn` | `Number => Void` | The function to be executed on each number in the range |
|
|
233
|
+
| `range` | `Range<Number>` | The range to iterate |
|
|
234
234
|
|
|
235
235
|
Examples:
|
|
236
236
|
|
|
@@ -264,16 +264,16 @@ always changed by `1`, even if non-integer values were provided in the range.
|
|
|
264
264
|
|
|
265
265
|
Parameters:
|
|
266
266
|
|
|
267
|
-
|param|type|description|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
267
|
+
| param | type | description |
|
|
268
|
+
| ------- | --------------- | ------------------------------------------------------------------------------------------ |
|
|
269
|
+
| `fn` | `Number => a` | The function called on each number in the range that returns the value for the output list |
|
|
270
|
+
| `range` | `Range<Number>` | The range to iterate |
|
|
271
271
|
|
|
272
272
|
Returns:
|
|
273
273
|
|
|
274
|
-
|type|description|
|
|
275
|
-
|
|
276
|
-
|
|
274
|
+
| type | description |
|
|
275
|
+
| --------- | --------------------------------------------------- |
|
|
276
|
+
| `List<a>` | A list containing all values returned from the `fn` |
|
|
277
277
|
|
|
278
278
|
Examples:
|
|
279
279
|
|
package/rational.md
CHANGED
|
@@ -40,15 +40,15 @@ Converts a Number to a Rational.
|
|
|
40
40
|
|
|
41
41
|
Parameters:
|
|
42
42
|
|
|
43
|
-
|param|type|description|
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
| param | type | description |
|
|
44
|
+
| -------- | -------- | -------------------- |
|
|
45
|
+
| `number` | `Number` | The value to convert |
|
|
46
46
|
|
|
47
47
|
Returns:
|
|
48
48
|
|
|
49
|
-
|type|description|
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
| type | description |
|
|
50
|
+
| ---------- | ------------------------------------ |
|
|
51
|
+
| `Rational` | The Number represented as a Rational |
|
|
52
52
|
|
|
53
53
|
### Rational.**toNumber**
|
|
54
54
|
|
|
@@ -65,15 +65,15 @@ Converts a Rational to a Number.
|
|
|
65
65
|
|
|
66
66
|
Parameters:
|
|
67
67
|
|
|
68
|
-
|param|type|description|
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
| param | type | description |
|
|
69
|
+
| ---------- | ---------- | -------------------- |
|
|
70
|
+
| `rational` | `Rational` | The value to convert |
|
|
71
71
|
|
|
72
72
|
Returns:
|
|
73
73
|
|
|
74
|
-
|type|description|
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
| type | description |
|
|
75
|
+
| -------- | ------------------------------------ |
|
|
76
|
+
| `Number` | The Rational represented as a Number |
|
|
77
77
|
|
|
78
78
|
### Rational.**numerator**
|
|
79
79
|
|
|
@@ -90,15 +90,15 @@ Finds the numerator of the rational number.
|
|
|
90
90
|
|
|
91
91
|
Parameters:
|
|
92
92
|
|
|
93
|
-
|param|type|description|
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
| param | type | description |
|
|
94
|
+
| ----- | ---------- | ------------------------------ |
|
|
95
|
+
| `x` | `Rational` | The rational number to inspect |
|
|
96
96
|
|
|
97
97
|
Returns:
|
|
98
98
|
|
|
99
|
-
|type|description|
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
| type | description |
|
|
100
|
+
| -------- | ------------------------------------ |
|
|
101
|
+
| `Number` | The numerator of the rational number |
|
|
102
102
|
|
|
103
103
|
### Rational.**denominator**
|
|
104
104
|
|
|
@@ -115,15 +115,15 @@ Finds the denominator of the rational number.
|
|
|
115
115
|
|
|
116
116
|
Parameters:
|
|
117
117
|
|
|
118
|
-
|param|type|description|
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
| param | type | description |
|
|
119
|
+
| ----- | ---------- | ------------------------------ |
|
|
120
|
+
| `x` | `Rational` | The rational number to inspect |
|
|
121
121
|
|
|
122
122
|
Returns:
|
|
123
123
|
|
|
124
|
-
|type|description|
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
| type | description |
|
|
125
|
+
| -------- | -------------------------------------- |
|
|
126
|
+
| `Number` | The denominator of the rational number |
|
|
127
127
|
|
|
128
128
|
### Rational.**toIntegerRatio**
|
|
129
129
|
|
|
@@ -140,15 +140,15 @@ Gets the numerator and denominator of the rational.
|
|
|
140
140
|
|
|
141
141
|
Parameters:
|
|
142
142
|
|
|
143
|
-
|param|type|description|
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
| param | type | description |
|
|
144
|
+
| ----- | ---------- | --------------------- |
|
|
145
|
+
| `x` | `Rational` | The rational to split |
|
|
146
146
|
|
|
147
147
|
Returns:
|
|
148
148
|
|
|
149
|
-
|type|description|
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
| type | description |
|
|
150
|
+
| ------------------ | --------------------------------------------- |
|
|
151
|
+
| `(Number, Number)` | The numerator and denominator of the rational |
|
|
152
152
|
|
|
153
153
|
Examples:
|
|
154
154
|
|
|
@@ -175,16 +175,16 @@ Creates a rational from a numerator and denominator.
|
|
|
175
175
|
|
|
176
176
|
Parameters:
|
|
177
177
|
|
|
178
|
-
|param|type|description|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
| param | type | description |
|
|
179
|
+
| ------------- | -------- | --------------- |
|
|
180
|
+
| `numerator` | `Number` | The numerator |
|
|
181
|
+
| `denominator` | `Number` | The denominator |
|
|
182
182
|
|
|
183
183
|
Returns:
|
|
184
184
|
|
|
185
|
-
|type|description|
|
|
186
|
-
|
|
187
|
-
|
|
185
|
+
| type | description |
|
|
186
|
+
| ---------- | -------------------- |
|
|
187
|
+
| `Rational` | The reduced rational |
|
|
188
188
|
|
|
189
189
|
Throws:
|
|
190
190
|
|
|
@@ -218,16 +218,16 @@ Computes the sum of its operands.
|
|
|
218
218
|
|
|
219
219
|
Parameters:
|
|
220
220
|
|
|
221
|
-
|param|type|description|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
221
|
+
| param | type | description |
|
|
222
|
+
| ----- | ---------- | ------------------ |
|
|
223
|
+
| `x` | `Rational` | The first operand |
|
|
224
|
+
| `y` | `Rational` | The second operand |
|
|
225
225
|
|
|
226
226
|
Returns:
|
|
227
227
|
|
|
228
|
-
|type|description|
|
|
229
|
-
|
|
230
|
-
|
|
228
|
+
| type | description |
|
|
229
|
+
| ---------- | --------------------------- |
|
|
230
|
+
| `Rational` | The sum of the two operands |
|
|
231
231
|
|
|
232
232
|
Examples:
|
|
233
233
|
|
|
@@ -251,16 +251,16 @@ Computes the difference of its operands.
|
|
|
251
251
|
|
|
252
252
|
Parameters:
|
|
253
253
|
|
|
254
|
-
|param|type|description|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
254
|
+
| param | type | description |
|
|
255
|
+
| ----- | ---------- | ------------------ |
|
|
256
|
+
| `x` | `Rational` | The first operand |
|
|
257
|
+
| `y` | `Rational` | The second operand |
|
|
258
258
|
|
|
259
259
|
Returns:
|
|
260
260
|
|
|
261
|
-
|type|description|
|
|
262
|
-
|
|
263
|
-
|
|
261
|
+
| type | description |
|
|
262
|
+
| ---------- | ---------------------------------- |
|
|
263
|
+
| `Rational` | The difference of the two operands |
|
|
264
264
|
|
|
265
265
|
Examples:
|
|
266
266
|
|
|
@@ -284,16 +284,16 @@ Computes the product of its operands.
|
|
|
284
284
|
|
|
285
285
|
Parameters:
|
|
286
286
|
|
|
287
|
-
|param|type|description|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
287
|
+
| param | type | description |
|
|
288
|
+
| ----- | ---------- | ------------------ |
|
|
289
|
+
| `x` | `Rational` | The first operand |
|
|
290
|
+
| `y` | `Rational` | The second operand |
|
|
291
291
|
|
|
292
292
|
Returns:
|
|
293
293
|
|
|
294
|
-
|type|description|
|
|
295
|
-
|
|
296
|
-
|
|
294
|
+
| type | description |
|
|
295
|
+
| ---------- | ------------------------------- |
|
|
296
|
+
| `Rational` | The product of the two operands |
|
|
297
297
|
|
|
298
298
|
Examples:
|
|
299
299
|
|
|
@@ -317,16 +317,16 @@ Computes the quotient of its operands.
|
|
|
317
317
|
|
|
318
318
|
Parameters:
|
|
319
319
|
|
|
320
|
-
|param|type|description|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
320
|
+
| param | type | description |
|
|
321
|
+
| ----- | ---------- | ------------------ |
|
|
322
|
+
| `x` | `Rational` | The first operand |
|
|
323
|
+
| `y` | `Rational` | The second operand |
|
|
324
324
|
|
|
325
325
|
Returns:
|
|
326
326
|
|
|
327
|
-
|type|description|
|
|
328
|
-
|
|
329
|
-
|
|
327
|
+
| type | description |
|
|
328
|
+
| ---------- | -------------------------------- |
|
|
329
|
+
| `Rational` | The quotient of the two operands |
|
|
330
330
|
|
|
331
331
|
Examples:
|
|
332
332
|
|
|
@@ -350,16 +350,16 @@ Checks if the first value is equal to the second value.
|
|
|
350
350
|
|
|
351
351
|
Parameters:
|
|
352
352
|
|
|
353
|
-
|param|type|description|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
353
|
+
| param | type | description |
|
|
354
|
+
| ----- | ---------- | ---------------- |
|
|
355
|
+
| `x` | `Rational` | The first value |
|
|
356
|
+
| `y` | `Rational` | The second value |
|
|
357
357
|
|
|
358
358
|
Returns:
|
|
359
359
|
|
|
360
|
-
|type|description|
|
|
361
|
-
|
|
362
|
-
|
|
360
|
+
| type | description |
|
|
361
|
+
| ------ | --------------------------------------------------------------------------- |
|
|
362
|
+
| `Bool` | `true` if the first value is equal to the second value or `false` otherwise |
|
|
363
363
|
|
|
364
364
|
Examples:
|
|
365
365
|
|
|
@@ -383,16 +383,16 @@ Checks if the first value is not equal to the second value.
|
|
|
383
383
|
|
|
384
384
|
Parameters:
|
|
385
385
|
|
|
386
|
-
|param|type|description|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
386
|
+
| param | type | description |
|
|
387
|
+
| ----- | ---------- | ---------------- |
|
|
388
|
+
| `x` | `Rational` | The first value |
|
|
389
|
+
| `y` | `Rational` | The second value |
|
|
390
390
|
|
|
391
391
|
Returns:
|
|
392
392
|
|
|
393
|
-
|type|description|
|
|
394
|
-
|
|
395
|
-
|
|
393
|
+
| type | description |
|
|
394
|
+
| ------ | ------------------------------------------------------------------------------- |
|
|
395
|
+
| `Bool` | `true` if the first value is not equal to the second value or `false` otherwise |
|
|
396
396
|
|
|
397
397
|
Examples:
|
|
398
398
|
|
|
@@ -416,16 +416,16 @@ Checks if the first value is less than the second value.
|
|
|
416
416
|
|
|
417
417
|
Parameters:
|
|
418
418
|
|
|
419
|
-
|param|type|description|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
419
|
+
| param | type | description |
|
|
420
|
+
| ----- | ---------- | ---------------- |
|
|
421
|
+
| `x` | `Rational` | The first value |
|
|
422
|
+
| `y` | `Rational` | The second value |
|
|
423
423
|
|
|
424
424
|
Returns:
|
|
425
425
|
|
|
426
|
-
|type|description|
|
|
427
|
-
|
|
428
|
-
|
|
426
|
+
| type | description |
|
|
427
|
+
| ------ | ---------------------------------------------------------------------------- |
|
|
428
|
+
| `Bool` | `true` if the first value is less than the second value or `false` otherwise |
|
|
429
429
|
|
|
430
430
|
Examples:
|
|
431
431
|
|
|
@@ -449,16 +449,16 @@ Checks if the first value is greater than the second value.
|
|
|
449
449
|
|
|
450
450
|
Parameters:
|
|
451
451
|
|
|
452
|
-
|param|type|description|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
452
|
+
| param | type | description |
|
|
453
|
+
| ----- | ---------- | ---------------- |
|
|
454
|
+
| `x` | `Rational` | The first value |
|
|
455
|
+
| `y` | `Rational` | The second value |
|
|
456
456
|
|
|
457
457
|
Returns:
|
|
458
458
|
|
|
459
|
-
|type|description|
|
|
460
|
-
|
|
461
|
-
|
|
459
|
+
| type | description |
|
|
460
|
+
| ------ | ------------------------------------------------------------------------------- |
|
|
461
|
+
| `Bool` | `true` if the first value is greater than the second value or `false` otherwise |
|
|
462
462
|
|
|
463
463
|
Examples:
|
|
464
464
|
|
|
@@ -482,16 +482,16 @@ Checks if the first value is less than or equal to the second value.
|
|
|
482
482
|
|
|
483
483
|
Parameters:
|
|
484
484
|
|
|
485
|
-
|param|type|description|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
485
|
+
| param | type | description |
|
|
486
|
+
| ----- | ---------- | ---------------- |
|
|
487
|
+
| `x` | `Rational` | The first value |
|
|
488
|
+
| `y` | `Rational` | The second value |
|
|
489
489
|
|
|
490
490
|
Returns:
|
|
491
491
|
|
|
492
|
-
|type|description|
|
|
493
|
-
|
|
494
|
-
|
|
492
|
+
| type | description |
|
|
493
|
+
| ------ | ---------------------------------------------------------------------------------------- |
|
|
494
|
+
| `Bool` | `true` if the first value is less than or equal to the second value or `false` otherwise |
|
|
495
495
|
|
|
496
496
|
Examples:
|
|
497
497
|
|
|
@@ -520,16 +520,16 @@ Checks if the first value is greater than or equal to the second value.
|
|
|
520
520
|
|
|
521
521
|
Parameters:
|
|
522
522
|
|
|
523
|
-
|param|type|description|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
523
|
+
| param | type | description |
|
|
524
|
+
| ----- | ---------- | ---------------- |
|
|
525
|
+
| `x` | `Rational` | The first value |
|
|
526
|
+
| `y` | `Rational` | The second value |
|
|
527
527
|
|
|
528
528
|
Returns:
|
|
529
529
|
|
|
530
|
-
|type|description|
|
|
531
|
-
|
|
532
|
-
|
|
530
|
+
| type | description |
|
|
531
|
+
| ------ | ------------------------------------------------------------------------------------------- |
|
|
532
|
+
| `Bool` | `true` if the first value is greater than or equal to the second value or `false` otherwise |
|
|
533
533
|
|
|
534
534
|
Examples:
|
|
535
535
|
|