@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/stack.md
CHANGED
|
@@ -51,15 +51,15 @@ default size.
|
|
|
51
51
|
|
|
52
52
|
Parameters:
|
|
53
53
|
|
|
54
|
-
|param|type|description|
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
| param | type | description |
|
|
55
|
+
| ------- | -------- | ------------------------------------- |
|
|
56
|
+
| `?size` | `Number` | The initial storage size of the stack |
|
|
57
57
|
|
|
58
58
|
Returns:
|
|
59
59
|
|
|
60
|
-
|type|description|
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
| type | description |
|
|
61
|
+
| ---------- | -------------- |
|
|
62
|
+
| `Stack<a>` | An empty stack |
|
|
63
63
|
|
|
64
64
|
### Stack.**isEmpty**
|
|
65
65
|
|
|
@@ -76,15 +76,15 @@ Checks if the given stack contains no items.
|
|
|
76
76
|
|
|
77
77
|
Parameters:
|
|
78
78
|
|
|
79
|
-
|param|type|description|
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
| param | type | description |
|
|
80
|
+
| ------- | ---------- | ------------------ |
|
|
81
|
+
| `stack` | `Stack<a>` | The stack to check |
|
|
82
82
|
|
|
83
83
|
Returns:
|
|
84
84
|
|
|
85
|
-
|type|description|
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
| type | description |
|
|
86
|
+
| ------ | ----------------------------------------------------- |
|
|
87
|
+
| `Bool` | `true` if the stack has no items or `false` otherwise |
|
|
88
88
|
|
|
89
89
|
### Stack.**size**
|
|
90
90
|
|
|
@@ -101,15 +101,15 @@ Computes the size of the input stack.
|
|
|
101
101
|
|
|
102
102
|
Parameters:
|
|
103
103
|
|
|
104
|
-
|param|type|description|
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
| param | type | description |
|
|
105
|
+
| ------- | ---------- | -------------------- |
|
|
106
|
+
| `stack` | `Stack<a>` | The stack to inspect |
|
|
107
107
|
|
|
108
108
|
Returns:
|
|
109
109
|
|
|
110
|
-
|type|description|
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
| type | description |
|
|
111
|
+
| -------- | ----------------------------------- |
|
|
112
|
+
| `Number` | The count of the items in the stack |
|
|
113
113
|
|
|
114
114
|
### Stack.**peek**
|
|
115
115
|
|
|
@@ -126,15 +126,15 @@ Provides the value at the top of the stack, if it exists.
|
|
|
126
126
|
|
|
127
127
|
Parameters:
|
|
128
128
|
|
|
129
|
-
|param|type|description|
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
| param | type | description |
|
|
130
|
+
| ------- | ---------- | -------------------- |
|
|
131
|
+
| `stack` | `Stack<a>` | The stack to inspect |
|
|
132
132
|
|
|
133
133
|
Returns:
|
|
134
134
|
|
|
135
|
-
|type|description|
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
| type | description |
|
|
136
|
+
| ----------- | ------------------------------------------------------------------------------- |
|
|
137
|
+
| `Option<a>` | `Some(value)` containing the value at the top of the stack or `None` otherwise. |
|
|
138
138
|
|
|
139
139
|
### Stack.**push**
|
|
140
140
|
|
|
@@ -151,10 +151,10 @@ Adds a new item to the top of the stack.
|
|
|
151
151
|
|
|
152
152
|
Parameters:
|
|
153
153
|
|
|
154
|
-
|param|type|description|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
| param | type | description |
|
|
155
|
+
| ------- | ---------- | ----------------------- |
|
|
156
|
+
| `value` | `a` | The item to be added |
|
|
157
|
+
| `stack` | `Stack<a>` | The stack being updated |
|
|
158
158
|
|
|
159
159
|
### Stack.**pop**
|
|
160
160
|
|
|
@@ -171,15 +171,15 @@ Removes the item at the top of the stack.
|
|
|
171
171
|
|
|
172
172
|
Parameters:
|
|
173
173
|
|
|
174
|
-
|param|type|description|
|
|
175
|
-
|
|
176
|
-
|
|
174
|
+
| param | type | description |
|
|
175
|
+
| ------- | ---------- | ----------------------- |
|
|
176
|
+
| `stack` | `Stack<a>` | The stack being updated |
|
|
177
177
|
|
|
178
178
|
Returns:
|
|
179
179
|
|
|
180
|
-
|type|description|
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
| type | description |
|
|
181
|
+
| ----------- | ---------------------------------- |
|
|
182
|
+
| `Option<a>` | The element removed from the stack |
|
|
183
183
|
|
|
184
184
|
### Stack.**clear**
|
|
185
185
|
|
|
@@ -196,9 +196,9 @@ Clears the stack by removing all of its elements
|
|
|
196
196
|
|
|
197
197
|
Parameters:
|
|
198
198
|
|
|
199
|
-
|param|type|description|
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
| param | type | description |
|
|
200
|
+
| ------- | ---------- | ------------------ |
|
|
201
|
+
| `stack` | `Stack<a>` | The stack to clear |
|
|
202
202
|
|
|
203
203
|
### Stack.**copy**
|
|
204
204
|
|
|
@@ -215,15 +215,15 @@ Produces a shallow copy of the input stack.
|
|
|
215
215
|
|
|
216
216
|
Parameters:
|
|
217
217
|
|
|
218
|
-
|param|type|description|
|
|
219
|
-
|
|
220
|
-
|
|
218
|
+
| param | type | description |
|
|
219
|
+
| ------- | ---------- | ----------------- |
|
|
220
|
+
| `stack` | `Stack<a>` | The stack to copy |
|
|
221
221
|
|
|
222
222
|
Returns:
|
|
223
223
|
|
|
224
|
-
|type|description|
|
|
225
|
-
|
|
226
|
-
|
|
224
|
+
| type | description |
|
|
225
|
+
| ---------- | -------------------------------------------------- |
|
|
226
|
+
| `Stack<a>` | A new stack containing the elements from the input |
|
|
227
227
|
|
|
228
228
|
### Stack.**toList**
|
|
229
229
|
|
|
@@ -240,15 +240,15 @@ Creates a list containing the elements of a stack.
|
|
|
240
240
|
|
|
241
241
|
Parameters:
|
|
242
242
|
|
|
243
|
-
|param|type|description|
|
|
244
|
-
|
|
245
|
-
|
|
243
|
+
| param | type | description |
|
|
244
|
+
| ------- | ---------- | -------------------- |
|
|
245
|
+
| `stack` | `Stack<a>` | The stack to convert |
|
|
246
246
|
|
|
247
247
|
Returns:
|
|
248
248
|
|
|
249
|
-
|type|description|
|
|
250
|
-
|
|
251
|
-
|
|
249
|
+
| type | description |
|
|
250
|
+
| --------- | ---------------------------------- |
|
|
251
|
+
| `List<a>` | A list containing all stack values |
|
|
252
252
|
|
|
253
253
|
Examples:
|
|
254
254
|
|
|
@@ -274,15 +274,15 @@ Creates a stack from a list.
|
|
|
274
274
|
|
|
275
275
|
Parameters:
|
|
276
276
|
|
|
277
|
-
|param|type|description|
|
|
278
|
-
|
|
279
|
-
|
|
277
|
+
| param | type | description |
|
|
278
|
+
| ------ | --------- | ------------------- |
|
|
279
|
+
| `list` | `List<a>` | The list to convert |
|
|
280
280
|
|
|
281
281
|
Returns:
|
|
282
282
|
|
|
283
|
-
|type|description|
|
|
284
|
-
|
|
285
|
-
|
|
283
|
+
| type | description |
|
|
284
|
+
| ---------- | ---------------------------------- |
|
|
285
|
+
| `Stack<a>` | A stack containing all list values |
|
|
286
286
|
|
|
287
287
|
Examples:
|
|
288
288
|
|
|
@@ -309,15 +309,15 @@ Creates an array containing the elements of a stack.
|
|
|
309
309
|
|
|
310
310
|
Parameters:
|
|
311
311
|
|
|
312
|
-
|param|type|description|
|
|
313
|
-
|
|
314
|
-
|
|
312
|
+
| param | type | description |
|
|
313
|
+
| ------- | ---------- | -------------------- |
|
|
314
|
+
| `stack` | `Stack<a>` | The stack to convert |
|
|
315
315
|
|
|
316
316
|
Returns:
|
|
317
317
|
|
|
318
|
-
|type|description|
|
|
319
|
-
|
|
320
|
-
|
|
318
|
+
| type | description |
|
|
319
|
+
| ---------- | ------------------------------------ |
|
|
320
|
+
| `Array<a>` | An array containing all stack values |
|
|
321
321
|
|
|
322
322
|
Examples:
|
|
323
323
|
|
|
@@ -343,15 +343,15 @@ Creates a stack from an array.
|
|
|
343
343
|
|
|
344
344
|
Parameters:
|
|
345
345
|
|
|
346
|
-
|param|type|description|
|
|
347
|
-
|
|
348
|
-
|
|
346
|
+
| param | type | description |
|
|
347
|
+
| ----- | ---------- | -------------------- |
|
|
348
|
+
| `arr` | `Array<a>` | The array to convert |
|
|
349
349
|
|
|
350
350
|
Returns:
|
|
351
351
|
|
|
352
|
-
|type|description|
|
|
353
|
-
|
|
354
|
-
|
|
352
|
+
| type | description |
|
|
353
|
+
| ---------- | ----------------------------------- |
|
|
354
|
+
| `Stack<a>` | A stack containing all array values |
|
|
355
355
|
|
|
356
356
|
Examples:
|
|
357
357
|
|
|
@@ -425,15 +425,15 @@ Checks if the given stack contains no items.
|
|
|
425
425
|
|
|
426
426
|
Parameters:
|
|
427
427
|
|
|
428
|
-
|param|type|description|
|
|
429
|
-
|
|
430
|
-
|
|
428
|
+
| param | type | description |
|
|
429
|
+
| ------- | ------------------- | ------------------ |
|
|
430
|
+
| `stack` | `ImmutableStack<a>` | The stack to check |
|
|
431
431
|
|
|
432
432
|
Returns:
|
|
433
433
|
|
|
434
|
-
|type|description|
|
|
435
|
-
|
|
436
|
-
|
|
434
|
+
| type | description |
|
|
435
|
+
| ------ | ----------------------------------------------------- |
|
|
436
|
+
| `Bool` | `true` if the stack has no items or `false` otherwise |
|
|
437
437
|
|
|
438
438
|
#### Stack.Immutable.**peek**
|
|
439
439
|
|
|
@@ -458,15 +458,15 @@ Provides the value at the top of the stack, if it exists.
|
|
|
458
458
|
|
|
459
459
|
Parameters:
|
|
460
460
|
|
|
461
|
-
|param|type|description|
|
|
462
|
-
|
|
463
|
-
|
|
461
|
+
| param | type | description |
|
|
462
|
+
| ------- | ------------------- | -------------------- |
|
|
463
|
+
| `stack` | `ImmutableStack<a>` | The stack to inspect |
|
|
464
464
|
|
|
465
465
|
Returns:
|
|
466
466
|
|
|
467
|
-
|type|description|
|
|
468
|
-
|
|
469
|
-
|
|
467
|
+
| type | description |
|
|
468
|
+
| ----------- | ------------------------------------------------------------------------------- |
|
|
469
|
+
| `Option<a>` | `Some(value)` containing the value at the top of the stack or `None` otherwise. |
|
|
470
470
|
|
|
471
471
|
#### Stack.Immutable.**push**
|
|
472
472
|
|
|
@@ -490,16 +490,16 @@ Adds a new item to the top of the stack.
|
|
|
490
490
|
|
|
491
491
|
Parameters:
|
|
492
492
|
|
|
493
|
-
|param|type|description|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
493
|
+
| param | type | description |
|
|
494
|
+
| ------- | ------------------- | ----------------------- |
|
|
495
|
+
| `value` | `a` | The item to be added |
|
|
496
|
+
| `stack` | `ImmutableStack<a>` | The stack being updated |
|
|
497
497
|
|
|
498
498
|
Returns:
|
|
499
499
|
|
|
500
|
-
|type|description|
|
|
501
|
-
|
|
502
|
-
|
|
500
|
+
| type | description |
|
|
501
|
+
| ------------------- | ------------------------------------------ |
|
|
502
|
+
| `ImmutableStack<a>` | A new stack with the item added to the end |
|
|
503
503
|
|
|
504
504
|
#### Stack.Immutable.**pop**
|
|
505
505
|
|
|
@@ -523,15 +523,15 @@ Removes the item at the top of the stack.
|
|
|
523
523
|
|
|
524
524
|
Parameters:
|
|
525
525
|
|
|
526
|
-
|param|type|description|
|
|
527
|
-
|
|
528
|
-
|
|
526
|
+
| param | type | description |
|
|
527
|
+
| ------- | ------------------- | ----------------------- |
|
|
528
|
+
| `stack` | `ImmutableStack<a>` | The stack being updated |
|
|
529
529
|
|
|
530
530
|
Returns:
|
|
531
531
|
|
|
532
|
-
|type|description|
|
|
533
|
-
|
|
534
|
-
|
|
532
|
+
| type | description |
|
|
533
|
+
| ------------------- | -------------------------------------- |
|
|
534
|
+
| `ImmutableStack<a>` | A new stack with the last item removed |
|
|
535
535
|
|
|
536
536
|
#### Stack.Immutable.**size**
|
|
537
537
|
|
|
@@ -555,15 +555,15 @@ Computes the size of the input stack.
|
|
|
555
555
|
|
|
556
556
|
Parameters:
|
|
557
557
|
|
|
558
|
-
|param|type|description|
|
|
559
|
-
|
|
560
|
-
|
|
558
|
+
| param | type | description |
|
|
559
|
+
| ------- | ------------------- | -------------------- |
|
|
560
|
+
| `stack` | `ImmutableStack<a>` | The stack to inspect |
|
|
561
561
|
|
|
562
562
|
Returns:
|
|
563
563
|
|
|
564
|
-
|type|description|
|
|
565
|
-
|
|
566
|
-
|
|
564
|
+
| type | description |
|
|
565
|
+
| -------- | ----------------------------------- |
|
|
566
|
+
| `Number` | The count of the items in the stack |
|
|
567
567
|
|
|
568
568
|
#### Stack.Immutable.**toList**
|
|
569
569
|
|
|
@@ -580,15 +580,15 @@ Creates a list containing the elements of a stack.
|
|
|
580
580
|
|
|
581
581
|
Parameters:
|
|
582
582
|
|
|
583
|
-
|param|type|description|
|
|
584
|
-
|
|
585
|
-
|
|
583
|
+
| param | type | description |
|
|
584
|
+
| ------- | ------------------- | -------------------- |
|
|
585
|
+
| `stack` | `ImmutableStack<a>` | The stack to convert |
|
|
586
586
|
|
|
587
587
|
Returns:
|
|
588
588
|
|
|
589
|
-
|type|description|
|
|
590
|
-
|
|
591
|
-
|
|
589
|
+
| type | description |
|
|
590
|
+
| --------- | ---------------------------------- |
|
|
591
|
+
| `List<a>` | A list containing all stack values |
|
|
592
592
|
|
|
593
593
|
Examples:
|
|
594
594
|
|
|
@@ -615,15 +615,15 @@ Creates a stack from a list.
|
|
|
615
615
|
|
|
616
616
|
Parameters:
|
|
617
617
|
|
|
618
|
-
|param|type|description|
|
|
619
|
-
|
|
620
|
-
|
|
618
|
+
| param | type | description |
|
|
619
|
+
| ------ | --------- | ------------------- |
|
|
620
|
+
| `list` | `List<a>` | The list to convert |
|
|
621
621
|
|
|
622
622
|
Returns:
|
|
623
623
|
|
|
624
|
-
|type|description|
|
|
625
|
-
|
|
626
|
-
|
|
624
|
+
| type | description |
|
|
625
|
+
| ------------------- | ---------------------------------- |
|
|
626
|
+
| `ImmutableStack<a>` | A stack containing all list values |
|
|
627
627
|
|
|
628
628
|
Examples:
|
|
629
629
|
|
|
@@ -652,15 +652,15 @@ Creates an array containing the elements of a stack.
|
|
|
652
652
|
|
|
653
653
|
Parameters:
|
|
654
654
|
|
|
655
|
-
|param|type|description|
|
|
656
|
-
|
|
657
|
-
|
|
655
|
+
| param | type | description |
|
|
656
|
+
| ------- | ------------------- | -------------------- |
|
|
657
|
+
| `stack` | `ImmutableStack<a>` | The stack to convert |
|
|
658
658
|
|
|
659
659
|
Returns:
|
|
660
660
|
|
|
661
|
-
|type|description|
|
|
662
|
-
|
|
663
|
-
|
|
661
|
+
| type | description |
|
|
662
|
+
| ---------- | ------------------------------------ |
|
|
663
|
+
| `Array<a>` | An array containing all stack values |
|
|
664
664
|
|
|
665
665
|
Examples:
|
|
666
666
|
|
|
@@ -687,15 +687,15 @@ Creates a stack from an array.
|
|
|
687
687
|
|
|
688
688
|
Parameters:
|
|
689
689
|
|
|
690
|
-
|param|type|description|
|
|
691
|
-
|
|
692
|
-
|
|
690
|
+
| param | type | description |
|
|
691
|
+
| ----- | ---------- | -------------------- |
|
|
692
|
+
| `arr` | `Array<a>` | The array to convert |
|
|
693
693
|
|
|
694
694
|
Returns:
|
|
695
695
|
|
|
696
|
-
|type|description|
|
|
697
|
-
|
|
698
|
-
|
|
696
|
+
| type | description |
|
|
697
|
+
| ------------------- | ----------------------------------- |
|
|
698
|
+
| `ImmutableStack<a>` | A stack containing all array values |
|
|
699
699
|
|
|
700
700
|
Examples:
|
|
701
701
|
|