@grain/stdlib 0.6.6 → 0.7.1
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 +67 -0
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/array.gr +55 -7
- package/array.md +606 -560
- package/bigint.md +228 -228
- package/buffer.gr +85 -53
- package/buffer.md +442 -319
- package/bytes.gr +112 -35
- package/bytes.md +299 -219
- package/char.gr +201 -99
- package/char.md +447 -120
- package/exception.gr +11 -11
- package/exception.md +29 -4
- package/float32.gr +327 -3
- package/float32.md +698 -111
- package/float64.gr +320 -3
- package/float64.md +698 -111
- package/fs.gr +1082 -0
- package/fs.md +630 -0
- package/hash.gr +142 -88
- package/hash.md +105 -17
- package/int16.md +178 -178
- package/int32.gr +26 -5
- package/int32.md +266 -231
- package/int64.gr +27 -2
- package/int64.md +266 -231
- package/int8.md +178 -178
- package/json.gr +366 -51
- package/json.md +431 -15
- package/list.gr +328 -31
- package/list.md +759 -336
- package/map.gr +20 -12
- package/map.md +266 -260
- package/marshal.gr +41 -40
- package/marshal.md +14 -14
- package/number.gr +278 -35
- package/number.md +688 -269
- package/option.md +162 -162
- package/package.json +5 -3
- package/path.gr +48 -0
- package/path.md +180 -89
- package/pervasives.gr +2 -2
- package/pervasives.md +275 -275
- package/priorityqueue.gr +7 -7
- package/priorityqueue.md +131 -131
- package/queue.gr +183 -29
- package/queue.md +404 -148
- package/random.md +43 -43
- package/range.gr +4 -4
- package/range.md +42 -42
- package/rational.md +123 -123
- package/regex.gr +52 -51
- package/regex.md +102 -102
- package/result.md +118 -118
- package/runtime/atof/common.md +39 -39
- package/runtime/atof/decimal.gr +6 -6
- package/runtime/atof/decimal.md +14 -14
- package/runtime/atof/lemire.gr +5 -5
- package/runtime/atof/lemire.md +1 -1
- package/runtime/atof/parse.gr +16 -16
- package/runtime/atof/parse.md +2 -2
- package/runtime/atof/slow.md +1 -1
- package/runtime/atof/table.md +2 -2
- package/runtime/atoi/parse.gr +3 -3
- package/runtime/atoi/parse.md +1 -1
- package/runtime/bigint.gr +15 -47
- package/runtime/bigint.md +54 -60
- package/runtime/compare.gr +2 -2
- package/runtime/compare.md +8 -8
- package/runtime/dataStructures.md +211 -211
- package/runtime/debugPrint.gr +4 -1
- package/runtime/debugPrint.md +9 -9
- package/runtime/equal.gr +99 -77
- package/runtime/equal.md +8 -8
- package/runtime/exception.gr +62 -82
- package/runtime/exception.md +62 -11
- package/runtime/gc.gr +39 -45
- package/runtime/gc.md +4 -4
- package/runtime/malloc.gr +7 -7
- package/runtime/malloc.md +13 -13
- package/runtime/math/kernel/cos.gr +70 -0
- package/runtime/math/kernel/cos.md +14 -0
- package/runtime/math/kernel/sin.gr +65 -0
- package/runtime/math/kernel/sin.md +14 -0
- package/runtime/math/kernel/tan.gr +136 -0
- package/runtime/math/kernel/tan.md +14 -0
- package/runtime/math/rempio2.gr +244 -0
- package/runtime/math/rempio2.md +14 -0
- package/runtime/math/trig.gr +130 -0
- package/runtime/math/trig.md +28 -0
- package/runtime/math/umuldi.gr +26 -0
- package/runtime/math/umuldi.md +14 -0
- package/runtime/numberUtils.gr +29 -29
- package/runtime/numberUtils.md +12 -12
- package/runtime/numbers.gr +373 -381
- package/runtime/numbers.md +348 -342
- package/runtime/string.gr +37 -105
- package/runtime/string.md +20 -26
- package/runtime/unsafe/constants.md +24 -24
- package/runtime/unsafe/conv.md +19 -19
- package/runtime/unsafe/memory.gr +24 -20
- package/runtime/unsafe/memory.md +27 -7
- package/runtime/unsafe/offsets.gr +36 -0
- package/runtime/unsafe/offsets.md +88 -0
- package/runtime/unsafe/panic.gr +28 -0
- package/runtime/unsafe/panic.md +14 -0
- package/runtime/unsafe/tags.md +32 -32
- package/runtime/unsafe/wasmf32.md +28 -28
- package/runtime/unsafe/wasmf64.md +28 -28
- package/runtime/unsafe/wasmi32.md +47 -47
- package/runtime/unsafe/wasmi64.md +50 -50
- package/runtime/utf8.gr +189 -0
- package/runtime/utf8.md +117 -0
- package/runtime/wasi.gr +4 -2
- package/runtime/wasi.md +147 -147
- package/set.gr +18 -11
- package/set.md +253 -247
- package/stack.gr +171 -2
- package/stack.md +371 -89
- package/string.gr +352 -557
- package/string.md +298 -255
- package/uint16.md +170 -170
- package/uint32.gr +25 -4
- package/uint32.md +249 -214
- package/uint64.gr +25 -5
- package/uint64.md +249 -214
- package/uint8.md +170 -170
- package/uri.gr +57 -53
- package/uri.md +88 -89
- package/wasi/file.gr +67 -59
- package/wasi/file.md +308 -308
- package/wasi/process.md +26 -26
- package/wasi/random.md +12 -12
- package/wasi/time.md +16 -16
- package/runtime/utils/printing.gr +0 -60
- package/runtime/utils/printing.md +0 -26
package/int32.md
CHANGED
|
@@ -33,22 +33,22 @@ No other changes yet.
|
|
|
33
33
|
</details>
|
|
34
34
|
|
|
35
35
|
```grain
|
|
36
|
-
fromNumber
|
|
36
|
+
fromNumber: (number: Number) => Int32
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
Converts a Number to an Int32.
|
|
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
|
+
| `Int32` | The Number represented as an Int32 |
|
|
52
52
|
|
|
53
53
|
### Int32.**toNumber**
|
|
54
54
|
|
|
@@ -58,22 +58,22 @@ No other changes yet.
|
|
|
58
58
|
</details>
|
|
59
59
|
|
|
60
60
|
```grain
|
|
61
|
-
toNumber
|
|
61
|
+
toNumber: (value: Int32) => Number
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
Converts an Int32 to a Number.
|
|
65
65
|
|
|
66
66
|
Parameters:
|
|
67
67
|
|
|
68
|
-
|param|type|description|
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
| param | type | description |
|
|
69
|
+
| ------- | ------- | -------------------- |
|
|
70
|
+
| `value` | `Int32` | The value to convert |
|
|
71
71
|
|
|
72
72
|
Returns:
|
|
73
73
|
|
|
74
|
-
|type|description|
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
| type | description |
|
|
75
|
+
| -------- | --------------------------------- |
|
|
76
|
+
| `Number` | The Int32 represented as a Number |
|
|
77
77
|
|
|
78
78
|
### Int32.**fromUint32**
|
|
79
79
|
|
|
@@ -83,22 +83,22 @@ No other changes yet.
|
|
|
83
83
|
</details>
|
|
84
84
|
|
|
85
85
|
```grain
|
|
86
|
-
fromUint32
|
|
86
|
+
fromUint32: (number: Uint32) => Int32
|
|
87
87
|
```
|
|
88
88
|
|
|
89
89
|
Converts a Uint32 to an Int32.
|
|
90
90
|
|
|
91
91
|
Parameters:
|
|
92
92
|
|
|
93
|
-
|param|type|description|
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
| param | type | description |
|
|
94
|
+
| -------- | -------- | -------------------- |
|
|
95
|
+
| `number` | `Uint32` | The value to convert |
|
|
96
96
|
|
|
97
97
|
Returns:
|
|
98
98
|
|
|
99
|
-
|type|description|
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
| type | description |
|
|
100
|
+
| ------- | ---------------------------------- |
|
|
101
|
+
| `Int32` | The Uint32 represented as an Int32 |
|
|
102
102
|
|
|
103
103
|
Examples:
|
|
104
104
|
|
|
@@ -106,6 +106,41 @@ Examples:
|
|
|
106
106
|
Int32.fromUint32(1ul) == 1l
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
+
### Int32.**reinterpretFloat32**
|
|
110
|
+
|
|
111
|
+
<details disabled>
|
|
112
|
+
<summary tabindex="-1">Added in <code>0.7.0</code></summary>
|
|
113
|
+
No other changes yet.
|
|
114
|
+
</details>
|
|
115
|
+
|
|
116
|
+
```grain
|
|
117
|
+
reinterpretFloat32: (value: Float32) => Int32
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Interprets a Float32 as an Int32.
|
|
121
|
+
|
|
122
|
+
Parameters:
|
|
123
|
+
|
|
124
|
+
| param | type | description |
|
|
125
|
+
| ------- | --------- | -------------------- |
|
|
126
|
+
| `value` | `Float32` | The value to convert |
|
|
127
|
+
|
|
128
|
+
Returns:
|
|
129
|
+
|
|
130
|
+
| type | description |
|
|
131
|
+
| ------- | ----------------------------------- |
|
|
132
|
+
| `Int32` | The Float32 interpreted as an Int32 |
|
|
133
|
+
|
|
134
|
+
Examples:
|
|
135
|
+
|
|
136
|
+
```grain
|
|
137
|
+
Int32.reinterpretFloat32(1.0f) == 1065353216l
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
```grain
|
|
141
|
+
Int32.reinterpretFloat32(-1.0f) == -1065353216l
|
|
142
|
+
```
|
|
143
|
+
|
|
109
144
|
### Int32.**incr**
|
|
110
145
|
|
|
111
146
|
<details disabled>
|
|
@@ -114,22 +149,22 @@ No other changes yet.
|
|
|
114
149
|
</details>
|
|
115
150
|
|
|
116
151
|
```grain
|
|
117
|
-
incr
|
|
152
|
+
incr: (value: Int32) => Int32
|
|
118
153
|
```
|
|
119
154
|
|
|
120
155
|
Increments the value by one.
|
|
121
156
|
|
|
122
157
|
Parameters:
|
|
123
158
|
|
|
124
|
-
|param|type|description|
|
|
125
|
-
|
|
126
|
-
|
|
159
|
+
| param | type | description |
|
|
160
|
+
| ------- | ------- | ---------------------- |
|
|
161
|
+
| `value` | `Int32` | The value to increment |
|
|
127
162
|
|
|
128
163
|
Returns:
|
|
129
164
|
|
|
130
|
-
|type|description|
|
|
131
|
-
|
|
132
|
-
|
|
165
|
+
| type | description |
|
|
166
|
+
| ------- | --------------------- |
|
|
167
|
+
| `Int32` | The incremented value |
|
|
133
168
|
|
|
134
169
|
Examples:
|
|
135
170
|
|
|
@@ -149,22 +184,22 @@ No other changes yet.
|
|
|
149
184
|
</details>
|
|
150
185
|
|
|
151
186
|
```grain
|
|
152
|
-
decr
|
|
187
|
+
decr: (value: Int32) => Int32
|
|
153
188
|
```
|
|
154
189
|
|
|
155
190
|
Decrements the value by one.
|
|
156
191
|
|
|
157
192
|
Parameters:
|
|
158
193
|
|
|
159
|
-
|param|type|description|
|
|
160
|
-
|
|
161
|
-
|
|
194
|
+
| param | type | description |
|
|
195
|
+
| ------- | ------- | ---------------------- |
|
|
196
|
+
| `value` | `Int32` | The value to decrement |
|
|
162
197
|
|
|
163
198
|
Returns:
|
|
164
199
|
|
|
165
|
-
|type|description|
|
|
166
|
-
|
|
167
|
-
|
|
200
|
+
| type | description |
|
|
201
|
+
| ------- | --------------------- |
|
|
202
|
+
| `Int32` | The decremented value |
|
|
168
203
|
|
|
169
204
|
Examples:
|
|
170
205
|
|
|
@@ -191,23 +226,23 @@ Int32.decr(0l) == -1l
|
|
|
191
226
|
</details>
|
|
192
227
|
|
|
193
228
|
```grain
|
|
194
|
-
(+)
|
|
229
|
+
(+): (x: Int32, y: Int32) => Int32
|
|
195
230
|
```
|
|
196
231
|
|
|
197
232
|
Computes the sum of its operands.
|
|
198
233
|
|
|
199
234
|
Parameters:
|
|
200
235
|
|
|
201
|
-
|param|type|description|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
236
|
+
| param | type | description |
|
|
237
|
+
| ----- | ------- | ------------------ |
|
|
238
|
+
| `x` | `Int32` | The first operand |
|
|
239
|
+
| `y` | `Int32` | The second operand |
|
|
205
240
|
|
|
206
241
|
Returns:
|
|
207
242
|
|
|
208
|
-
|type|description|
|
|
209
|
-
|
|
210
|
-
|
|
243
|
+
| type | description |
|
|
244
|
+
| ------- | --------------------------- |
|
|
245
|
+
| `Int32` | The sum of the two operands |
|
|
211
246
|
|
|
212
247
|
Examples:
|
|
213
248
|
|
|
@@ -231,23 +266,23 @@ assert 1l + 1l == 2l
|
|
|
231
266
|
</details>
|
|
232
267
|
|
|
233
268
|
```grain
|
|
234
|
-
(-)
|
|
269
|
+
(-): (x: Int32, y: Int32) => Int32
|
|
235
270
|
```
|
|
236
271
|
|
|
237
272
|
Computes the difference of its operands.
|
|
238
273
|
|
|
239
274
|
Parameters:
|
|
240
275
|
|
|
241
|
-
|param|type|description|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
276
|
+
| param | type | description |
|
|
277
|
+
| ----- | ------- | ------------------ |
|
|
278
|
+
| `x` | `Int32` | The first operand |
|
|
279
|
+
| `y` | `Int32` | The second operand |
|
|
245
280
|
|
|
246
281
|
Returns:
|
|
247
282
|
|
|
248
|
-
|type|description|
|
|
249
|
-
|
|
250
|
-
|
|
283
|
+
| type | description |
|
|
284
|
+
| ------- | ---------------------------------- |
|
|
285
|
+
| `Int32` | The difference of the two operands |
|
|
251
286
|
|
|
252
287
|
Examples:
|
|
253
288
|
|
|
@@ -271,23 +306,23 @@ assert 2l - 1l == 1l
|
|
|
271
306
|
</details>
|
|
272
307
|
|
|
273
308
|
```grain
|
|
274
|
-
(*)
|
|
309
|
+
(*): (x: Int32, y: Int32) => Int32
|
|
275
310
|
```
|
|
276
311
|
|
|
277
312
|
Computes the product of its operands.
|
|
278
313
|
|
|
279
314
|
Parameters:
|
|
280
315
|
|
|
281
|
-
|param|type|description|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
316
|
+
| param | type | description |
|
|
317
|
+
| ----- | ------- | ------------------ |
|
|
318
|
+
| `x` | `Int32` | The first operand |
|
|
319
|
+
| `y` | `Int32` | The second operand |
|
|
285
320
|
|
|
286
321
|
Returns:
|
|
287
322
|
|
|
288
|
-
|type|description|
|
|
289
|
-
|
|
290
|
-
|
|
323
|
+
| type | description |
|
|
324
|
+
| ------- | ------------------------------- |
|
|
325
|
+
| `Int32` | The product of the two operands |
|
|
291
326
|
|
|
292
327
|
Examples:
|
|
293
328
|
|
|
@@ -311,23 +346,23 @@ assert 2l * 2l == 4l
|
|
|
311
346
|
</details>
|
|
312
347
|
|
|
313
348
|
```grain
|
|
314
|
-
(/)
|
|
349
|
+
(/): (x: Int32, y: Int32) => Int32
|
|
315
350
|
```
|
|
316
351
|
|
|
317
352
|
Computes the quotient of its operands using signed division.
|
|
318
353
|
|
|
319
354
|
Parameters:
|
|
320
355
|
|
|
321
|
-
|param|type|description|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
356
|
+
| param | type | description |
|
|
357
|
+
| ----- | ------- | ------------------ |
|
|
358
|
+
| `x` | `Int32` | The first operand |
|
|
359
|
+
| `y` | `Int32` | The second operand |
|
|
325
360
|
|
|
326
361
|
Returns:
|
|
327
362
|
|
|
328
|
-
|type|description|
|
|
329
|
-
|
|
330
|
-
|
|
363
|
+
| type | description |
|
|
364
|
+
| ------- | ---------------------------- |
|
|
365
|
+
| `Int32` | The quotient of its operands |
|
|
331
366
|
|
|
332
367
|
Examples:
|
|
333
368
|
|
|
@@ -344,23 +379,23 @@ No other changes yet.
|
|
|
344
379
|
</details>
|
|
345
380
|
|
|
346
381
|
```grain
|
|
347
|
-
rem
|
|
382
|
+
rem: (x: Int32, y: Int32) => Int32
|
|
348
383
|
```
|
|
349
384
|
|
|
350
385
|
Computes the remainder of the division of its operands using signed division.
|
|
351
386
|
|
|
352
387
|
Parameters:
|
|
353
388
|
|
|
354
|
-
|param|type|description|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
389
|
+
| param | type | description |
|
|
390
|
+
| ----- | ------- | ------------------ |
|
|
391
|
+
| `x` | `Int32` | The first operand |
|
|
392
|
+
| `y` | `Int32` | The second operand |
|
|
358
393
|
|
|
359
394
|
Returns:
|
|
360
395
|
|
|
361
|
-
|type|description|
|
|
362
|
-
|
|
363
|
-
|
|
396
|
+
| type | description |
|
|
397
|
+
| ------- | ----------------------------- |
|
|
398
|
+
| `Int32` | The remainder of its operands |
|
|
364
399
|
|
|
365
400
|
Examples:
|
|
366
401
|
|
|
@@ -383,7 +418,7 @@ Int32.rem(8l, 3l) == 2l
|
|
|
383
418
|
</details>
|
|
384
419
|
|
|
385
420
|
```grain
|
|
386
|
-
(%)
|
|
421
|
+
(%): (x: Int32, y: Int32) => Int32
|
|
387
422
|
```
|
|
388
423
|
|
|
389
424
|
Computes the remainder of the division of the first operand by the second.
|
|
@@ -391,16 +426,16 @@ The result will have the sign of the second operand.
|
|
|
391
426
|
|
|
392
427
|
Parameters:
|
|
393
428
|
|
|
394
|
-
|param|type|description|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
429
|
+
| param | type | description |
|
|
430
|
+
| ----- | ------- | ------------------ |
|
|
431
|
+
| `x` | `Int32` | The first operand |
|
|
432
|
+
| `y` | `Int32` | The second operand |
|
|
398
433
|
|
|
399
434
|
Returns:
|
|
400
435
|
|
|
401
|
-
|type|description|
|
|
402
|
-
|
|
403
|
-
|
|
436
|
+
| type | description |
|
|
437
|
+
| ------- | --------------------------- |
|
|
438
|
+
| `Int32` | The modulus of its operands |
|
|
404
439
|
|
|
405
440
|
Throws:
|
|
406
441
|
|
|
@@ -423,23 +458,23 @@ No other changes yet.
|
|
|
423
458
|
</details>
|
|
424
459
|
|
|
425
460
|
```grain
|
|
426
|
-
rotl
|
|
461
|
+
rotl: (value: Int32, amount: Int32) => Int32
|
|
427
462
|
```
|
|
428
463
|
|
|
429
464
|
Rotates the bits of the value left by the given number of bits.
|
|
430
465
|
|
|
431
466
|
Parameters:
|
|
432
467
|
|
|
433
|
-
|param|type|description|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
468
|
+
| param | type | description |
|
|
469
|
+
| -------- | ------- | ------------------------------- |
|
|
470
|
+
| `value` | `Int32` | The value to rotate |
|
|
471
|
+
| `amount` | `Int32` | The number of bits to rotate by |
|
|
437
472
|
|
|
438
473
|
Returns:
|
|
439
474
|
|
|
440
|
-
|type|description|
|
|
441
|
-
|
|
442
|
-
|
|
475
|
+
| type | description |
|
|
476
|
+
| ------- | ----------------- |
|
|
477
|
+
| `Int32` | The rotated value |
|
|
443
478
|
|
|
444
479
|
Examples:
|
|
445
480
|
|
|
@@ -459,23 +494,23 @@ No other changes yet.
|
|
|
459
494
|
</details>
|
|
460
495
|
|
|
461
496
|
```grain
|
|
462
|
-
rotr
|
|
497
|
+
rotr: (value: Int32, amount: Int32) => Int32
|
|
463
498
|
```
|
|
464
499
|
|
|
465
500
|
Rotates the bits of the value right by the given number of bits.
|
|
466
501
|
|
|
467
502
|
Parameters:
|
|
468
503
|
|
|
469
|
-
|param|type|description|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
504
|
+
| param | type | description |
|
|
505
|
+
| -------- | ------- | ------------------------------- |
|
|
506
|
+
| `value` | `Int32` | The value to rotate |
|
|
507
|
+
| `amount` | `Int32` | The number of bits to rotate by |
|
|
473
508
|
|
|
474
509
|
Returns:
|
|
475
510
|
|
|
476
|
-
|type|description|
|
|
477
|
-
|
|
478
|
-
|
|
511
|
+
| type | description |
|
|
512
|
+
| ------- | ----------------- |
|
|
513
|
+
| `Int32` | The rotated value |
|
|
479
514
|
|
|
480
515
|
Examples:
|
|
481
516
|
|
|
@@ -502,23 +537,23 @@ Int32.rotr(4l, 2l) == 1l
|
|
|
502
537
|
</details>
|
|
503
538
|
|
|
504
539
|
```grain
|
|
505
|
-
(<<)
|
|
540
|
+
(<<): (value: Int32, amount: Int32) => Int32
|
|
506
541
|
```
|
|
507
542
|
|
|
508
543
|
Shifts the bits of the value left by the given number of bits.
|
|
509
544
|
|
|
510
545
|
Parameters:
|
|
511
546
|
|
|
512
|
-
|param|type|description|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
547
|
+
| param | type | description |
|
|
548
|
+
| -------- | ------- | ------------------------------ |
|
|
549
|
+
| `value` | `Int32` | The value to shift |
|
|
550
|
+
| `amount` | `Int32` | The number of bits to shift by |
|
|
516
551
|
|
|
517
552
|
Returns:
|
|
518
553
|
|
|
519
|
-
|type|description|
|
|
520
|
-
|
|
521
|
-
|
|
554
|
+
| type | description |
|
|
555
|
+
| ------- | ----------------- |
|
|
556
|
+
| `Int32` | The shifted value |
|
|
522
557
|
|
|
523
558
|
Examples:
|
|
524
559
|
|
|
@@ -542,23 +577,23 @@ assert (5l << 1l) == 10l
|
|
|
542
577
|
</details>
|
|
543
578
|
|
|
544
579
|
```grain
|
|
545
|
-
(>>)
|
|
580
|
+
(>>): (value: Int32, amount: Int32) => Int32
|
|
546
581
|
```
|
|
547
582
|
|
|
548
583
|
Shifts the bits of the value right by the given number of bits, preserving the sign bit.
|
|
549
584
|
|
|
550
585
|
Parameters:
|
|
551
586
|
|
|
552
|
-
|param|type|description|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
587
|
+
| param | type | description |
|
|
588
|
+
| -------- | ------- | ---------------------- |
|
|
589
|
+
| `value` | `Int32` | The value to shift |
|
|
590
|
+
| `amount` | `Int32` | The amount to shift by |
|
|
556
591
|
|
|
557
592
|
Returns:
|
|
558
593
|
|
|
559
|
-
|type|description|
|
|
560
|
-
|
|
561
|
-
|
|
594
|
+
| type | description |
|
|
595
|
+
| ------- | ----------------- |
|
|
596
|
+
| `Int32` | The shifted value |
|
|
562
597
|
|
|
563
598
|
Examples:
|
|
564
599
|
|
|
@@ -582,23 +617,23 @@ assert (5l >> 1l) == 2l
|
|
|
582
617
|
</details>
|
|
583
618
|
|
|
584
619
|
```grain
|
|
585
|
-
(==)
|
|
620
|
+
(==): (x: Int32, y: Int32) => Bool
|
|
586
621
|
```
|
|
587
622
|
|
|
588
623
|
Checks if the first value is equal to the second value.
|
|
589
624
|
|
|
590
625
|
Parameters:
|
|
591
626
|
|
|
592
|
-
|param|type|description|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
627
|
+
| param | type | description |
|
|
628
|
+
| ----- | ------- | ---------------- |
|
|
629
|
+
| `x` | `Int32` | The first value |
|
|
630
|
+
| `y` | `Int32` | The second value |
|
|
596
631
|
|
|
597
632
|
Returns:
|
|
598
633
|
|
|
599
|
-
|type|description|
|
|
600
|
-
|
|
601
|
-
|
|
634
|
+
| type | description |
|
|
635
|
+
| ------ | --------------------------------------------------------------------------- |
|
|
636
|
+
| `Bool` | `true` if the first value is equal to the second value or `false` otherwise |
|
|
602
637
|
|
|
603
638
|
Examples:
|
|
604
639
|
|
|
@@ -622,23 +657,23 @@ assert 1l == 1l
|
|
|
622
657
|
</details>
|
|
623
658
|
|
|
624
659
|
```grain
|
|
625
|
-
(!=)
|
|
660
|
+
(!=): (x: Int32, y: Int32) => Bool
|
|
626
661
|
```
|
|
627
662
|
|
|
628
663
|
Checks if the first value is not equal to the second value.
|
|
629
664
|
|
|
630
665
|
Parameters:
|
|
631
666
|
|
|
632
|
-
|param|type|description|
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
667
|
+
| param | type | description |
|
|
668
|
+
| ----- | ------- | ---------------- |
|
|
669
|
+
| `x` | `Int32` | The first value |
|
|
670
|
+
| `y` | `Int32` | The second value |
|
|
636
671
|
|
|
637
672
|
Returns:
|
|
638
673
|
|
|
639
|
-
|type|description|
|
|
640
|
-
|
|
641
|
-
|
|
674
|
+
| type | description |
|
|
675
|
+
| ------ | ------------------------------------------------------------------------------- |
|
|
676
|
+
| `Bool` | `true` if the first value is not equal to the second value or `false` otherwise |
|
|
642
677
|
|
|
643
678
|
Examples:
|
|
644
679
|
|
|
@@ -655,22 +690,22 @@ No other changes yet.
|
|
|
655
690
|
</details>
|
|
656
691
|
|
|
657
692
|
```grain
|
|
658
|
-
eqz
|
|
693
|
+
eqz: (value: Int32) => Bool
|
|
659
694
|
```
|
|
660
695
|
|
|
661
696
|
Checks if the given value is equal to zero.
|
|
662
697
|
|
|
663
698
|
Parameters:
|
|
664
699
|
|
|
665
|
-
|param|type|description|
|
|
666
|
-
|
|
667
|
-
|
|
700
|
+
| param | type | description |
|
|
701
|
+
| ------- | ------- | -------------------- |
|
|
702
|
+
| `value` | `Int32` | The value to inspect |
|
|
668
703
|
|
|
669
704
|
Returns:
|
|
670
705
|
|
|
671
|
-
|type|description|
|
|
672
|
-
|
|
673
|
-
|
|
706
|
+
| type | description |
|
|
707
|
+
| ------ | --------------------------------------------------------------- |
|
|
708
|
+
| `Bool` | `true` if the first value is equal to zero or `false` otherwise |
|
|
674
709
|
|
|
675
710
|
Examples:
|
|
676
711
|
|
|
@@ -697,23 +732,23 @@ Int32.eqz(1l) == false
|
|
|
697
732
|
</details>
|
|
698
733
|
|
|
699
734
|
```grain
|
|
700
|
-
(<)
|
|
735
|
+
(<): (x: Int32, y: Int32) => Bool
|
|
701
736
|
```
|
|
702
737
|
|
|
703
738
|
Checks if the first value is less than the second value.
|
|
704
739
|
|
|
705
740
|
Parameters:
|
|
706
741
|
|
|
707
|
-
|param|type|description|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
742
|
+
| param | type | description |
|
|
743
|
+
| ----- | ------- | ---------------- |
|
|
744
|
+
| `x` | `Int32` | The first value |
|
|
745
|
+
| `y` | `Int32` | The second value |
|
|
711
746
|
|
|
712
747
|
Returns:
|
|
713
748
|
|
|
714
|
-
|type|description|
|
|
715
|
-
|
|
716
|
-
|
|
749
|
+
| type | description |
|
|
750
|
+
| ------ | ---------------------------------------------------------------------------- |
|
|
751
|
+
| `Bool` | `true` if the first value is less than the second value or `false` otherwise |
|
|
717
752
|
|
|
718
753
|
Examples:
|
|
719
754
|
|
|
@@ -737,23 +772,23 @@ assert 1l < 2l
|
|
|
737
772
|
</details>
|
|
738
773
|
|
|
739
774
|
```grain
|
|
740
|
-
(>)
|
|
775
|
+
(>): (x: Int32, y: Int32) => Bool
|
|
741
776
|
```
|
|
742
777
|
|
|
743
778
|
Checks if the first value is greater than the second value.
|
|
744
779
|
|
|
745
780
|
Parameters:
|
|
746
781
|
|
|
747
|
-
|param|type|description|
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
782
|
+
| param | type | description |
|
|
783
|
+
| ----- | ------- | ---------------- |
|
|
784
|
+
| `x` | `Int32` | The first value |
|
|
785
|
+
| `y` | `Int32` | The second value |
|
|
751
786
|
|
|
752
787
|
Returns:
|
|
753
788
|
|
|
754
|
-
|type|description|
|
|
755
|
-
|
|
756
|
-
|
|
789
|
+
| type | description |
|
|
790
|
+
| ------ | ------------------------------------------------------------------------------- |
|
|
791
|
+
| `Bool` | `true` if the first value is greater than the second value or `false` otherwise |
|
|
757
792
|
|
|
758
793
|
Examples:
|
|
759
794
|
|
|
@@ -777,23 +812,23 @@ assert 2l > 1l
|
|
|
777
812
|
</details>
|
|
778
813
|
|
|
779
814
|
```grain
|
|
780
|
-
(<=)
|
|
815
|
+
(<=): (x: Int32, y: Int32) => Bool
|
|
781
816
|
```
|
|
782
817
|
|
|
783
818
|
Checks if the first value is less than or equal to the second value.
|
|
784
819
|
|
|
785
820
|
Parameters:
|
|
786
821
|
|
|
787
|
-
|param|type|description|
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
822
|
+
| param | type | description |
|
|
823
|
+
| ----- | ------- | ---------------- |
|
|
824
|
+
| `x` | `Int32` | The first value |
|
|
825
|
+
| `y` | `Int32` | The second value |
|
|
791
826
|
|
|
792
827
|
Returns:
|
|
793
828
|
|
|
794
|
-
|type|description|
|
|
795
|
-
|
|
796
|
-
|
|
829
|
+
| type | description |
|
|
830
|
+
| ------ | ---------------------------------------------------------------------------------------- |
|
|
831
|
+
| `Bool` | `true` if the first value is less than or equal to the second value or `false` otherwise |
|
|
797
832
|
|
|
798
833
|
Examples:
|
|
799
834
|
|
|
@@ -822,23 +857,23 @@ assert 1l <= 1l
|
|
|
822
857
|
</details>
|
|
823
858
|
|
|
824
859
|
```grain
|
|
825
|
-
(>=)
|
|
860
|
+
(>=): (x: Int32, y: Int32) => Bool
|
|
826
861
|
```
|
|
827
862
|
|
|
828
863
|
Checks if the first value is greater than or equal to the second value.
|
|
829
864
|
|
|
830
865
|
Parameters:
|
|
831
866
|
|
|
832
|
-
|param|type|description|
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
867
|
+
| param | type | description |
|
|
868
|
+
| ----- | ------- | ---------------- |
|
|
869
|
+
| `x` | `Int32` | The first value |
|
|
870
|
+
| `y` | `Int32` | The second value |
|
|
836
871
|
|
|
837
872
|
Returns:
|
|
838
873
|
|
|
839
|
-
|type|description|
|
|
840
|
-
|
|
841
|
-
|
|
874
|
+
| type | description |
|
|
875
|
+
| ------ | ------------------------------------------------------------------------------------------- |
|
|
876
|
+
| `Bool` | `true` if the first value is greater than or equal to the second value or `false` otherwise |
|
|
842
877
|
|
|
843
878
|
Examples:
|
|
844
879
|
|
|
@@ -860,22 +895,22 @@ No other changes yet.
|
|
|
860
895
|
</details>
|
|
861
896
|
|
|
862
897
|
```grain
|
|
863
|
-
lnot
|
|
898
|
+
lnot: (value: Int32) => Int32
|
|
864
899
|
```
|
|
865
900
|
|
|
866
901
|
Computes the bitwise NOT of the given value.
|
|
867
902
|
|
|
868
903
|
Parameters:
|
|
869
904
|
|
|
870
|
-
|param|type|description|
|
|
871
|
-
|
|
872
|
-
|
|
905
|
+
| param | type | description |
|
|
906
|
+
| ------- | ------- | --------------- |
|
|
907
|
+
| `value` | `Int32` | The given value |
|
|
873
908
|
|
|
874
909
|
Returns:
|
|
875
910
|
|
|
876
|
-
|type|description|
|
|
877
|
-
|
|
878
|
-
|
|
911
|
+
| type | description |
|
|
912
|
+
| ------- | ----------------------------------------------- |
|
|
913
|
+
| `Int32` | Containing the inverted bits of the given value |
|
|
879
914
|
|
|
880
915
|
Examples:
|
|
881
916
|
|
|
@@ -898,23 +933,23 @@ Int32.lnot(-5l) == 4l
|
|
|
898
933
|
</details>
|
|
899
934
|
|
|
900
935
|
```grain
|
|
901
|
-
(&)
|
|
936
|
+
(&): (x: Int32, y: Int32) => Int32
|
|
902
937
|
```
|
|
903
938
|
|
|
904
939
|
Computes the bitwise AND (`&`) on the given operands.
|
|
905
940
|
|
|
906
941
|
Parameters:
|
|
907
942
|
|
|
908
|
-
|param|type|description|
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
943
|
+
| param | type | description |
|
|
944
|
+
| ----- | ------- | ------------------ |
|
|
945
|
+
| `x` | `Int32` | The first operand |
|
|
946
|
+
| `y` | `Int32` | The second operand |
|
|
912
947
|
|
|
913
948
|
Returns:
|
|
914
949
|
|
|
915
|
-
|type|description|
|
|
916
|
-
|
|
917
|
-
|
|
950
|
+
| type | description |
|
|
951
|
+
| ------- | ----------------------------------------------------------------------------------------------- |
|
|
952
|
+
| `Int32` | Containing a `1` in each bit position for which the corresponding bits of both operands are `1` |
|
|
918
953
|
|
|
919
954
|
Examples:
|
|
920
955
|
|
|
@@ -938,23 +973,23 @@ assert (3l & 4l) == 0l
|
|
|
938
973
|
</details>
|
|
939
974
|
|
|
940
975
|
```grain
|
|
941
|
-
(|)
|
|
976
|
+
(|): (x: Int32, y: Int32) => Int32
|
|
942
977
|
```
|
|
943
978
|
|
|
944
979
|
Computes the bitwise OR (`|`) on the given operands.
|
|
945
980
|
|
|
946
981
|
Parameters:
|
|
947
982
|
|
|
948
|
-
|param|type|description|
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
983
|
+
| param | type | description |
|
|
984
|
+
| ----- | ------- | ------------------ |
|
|
985
|
+
| `x` | `Int32` | The first operand |
|
|
986
|
+
| `y` | `Int32` | The second operand |
|
|
952
987
|
|
|
953
988
|
Returns:
|
|
954
989
|
|
|
955
|
-
|type|description|
|
|
956
|
-
|
|
957
|
-
|
|
990
|
+
| type | description |
|
|
991
|
+
| ------- | --------------------------------------------------------------------------------------------------------- |
|
|
992
|
+
| `Int32` | Containing a `1` in each bit position for which the corresponding bits of either or both operands are `1` |
|
|
958
993
|
|
|
959
994
|
Examples:
|
|
960
995
|
|
|
@@ -978,23 +1013,23 @@ assert (3l | 4l) == 7l
|
|
|
978
1013
|
</details>
|
|
979
1014
|
|
|
980
1015
|
```grain
|
|
981
|
-
(^)
|
|
1016
|
+
(^): (x: Int32, y: Int32) => Int32
|
|
982
1017
|
```
|
|
983
1018
|
|
|
984
1019
|
Computes the bitwise XOR (`^`) on the given operands.
|
|
985
1020
|
|
|
986
1021
|
Parameters:
|
|
987
1022
|
|
|
988
|
-
|param|type|description|
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
1023
|
+
| param | type | description |
|
|
1024
|
+
| ----- | ------- | ------------------ |
|
|
1025
|
+
| `x` | `Int32` | The first operand |
|
|
1026
|
+
| `y` | `Int32` | The second operand |
|
|
992
1027
|
|
|
993
1028
|
Returns:
|
|
994
1029
|
|
|
995
|
-
|type|description|
|
|
996
|
-
|
|
997
|
-
|
|
1030
|
+
| type | description |
|
|
1031
|
+
| ------- | -------------------------------------------------------------------------------------------------------------- |
|
|
1032
|
+
| `Int32` | Containing a `1` in each bit position for which the corresponding bits of either but not both operands are `1` |
|
|
998
1033
|
|
|
999
1034
|
Examples:
|
|
1000
1035
|
|
|
@@ -1011,22 +1046,22 @@ No other changes yet.
|
|
|
1011
1046
|
</details>
|
|
1012
1047
|
|
|
1013
1048
|
```grain
|
|
1014
|
-
clz
|
|
1049
|
+
clz: (value: Int32) => Int32
|
|
1015
1050
|
```
|
|
1016
1051
|
|
|
1017
1052
|
Counts the number of leading zero bits in the value.
|
|
1018
1053
|
|
|
1019
1054
|
Parameters:
|
|
1020
1055
|
|
|
1021
|
-
|param|type|description|
|
|
1022
|
-
|
|
1023
|
-
|
|
1056
|
+
| param | type | description |
|
|
1057
|
+
| ------- | ------- | -------------------- |
|
|
1058
|
+
| `value` | `Int32` | The value to inspect |
|
|
1024
1059
|
|
|
1025
1060
|
Returns:
|
|
1026
1061
|
|
|
1027
|
-
|type|description|
|
|
1028
|
-
|
|
1029
|
-
|
|
1062
|
+
| type | description |
|
|
1063
|
+
| ------- | --------------------------- |
|
|
1064
|
+
| `Int32` | The amount of leading zeros |
|
|
1030
1065
|
|
|
1031
1066
|
Examples:
|
|
1032
1067
|
|
|
@@ -1046,22 +1081,22 @@ No other changes yet.
|
|
|
1046
1081
|
</details>
|
|
1047
1082
|
|
|
1048
1083
|
```grain
|
|
1049
|
-
ctz
|
|
1084
|
+
ctz: (value: Int32) => Int32
|
|
1050
1085
|
```
|
|
1051
1086
|
|
|
1052
1087
|
Counts the number of trailing zero bits in the value.
|
|
1053
1088
|
|
|
1054
1089
|
Parameters:
|
|
1055
1090
|
|
|
1056
|
-
|param|type|description|
|
|
1057
|
-
|
|
1058
|
-
|
|
1091
|
+
| param | type | description |
|
|
1092
|
+
| ------- | ------- | -------------------- |
|
|
1093
|
+
| `value` | `Int32` | The value to inspect |
|
|
1059
1094
|
|
|
1060
1095
|
Returns:
|
|
1061
1096
|
|
|
1062
|
-
|type|description|
|
|
1063
|
-
|
|
1064
|
-
|
|
1097
|
+
| type | description |
|
|
1098
|
+
| ------- | ---------------------------- |
|
|
1099
|
+
| `Int32` | The amount of trailing zeros |
|
|
1065
1100
|
|
|
1066
1101
|
Examples:
|
|
1067
1102
|
|
|
@@ -1081,22 +1116,22 @@ No other changes yet.
|
|
|
1081
1116
|
</details>
|
|
1082
1117
|
|
|
1083
1118
|
```grain
|
|
1084
|
-
popcnt
|
|
1119
|
+
popcnt: (value: Int32) => Int32
|
|
1085
1120
|
```
|
|
1086
1121
|
|
|
1087
1122
|
Counts the number of bits set to `1` in the value, also known as a population count.
|
|
1088
1123
|
|
|
1089
1124
|
Parameters:
|
|
1090
1125
|
|
|
1091
|
-
|param|type|description|
|
|
1092
|
-
|
|
1093
|
-
|
|
1126
|
+
| param | type | description |
|
|
1127
|
+
| ------- | ------- | -------------------- |
|
|
1128
|
+
| `value` | `Int32` | The value to inspect |
|
|
1094
1129
|
|
|
1095
1130
|
Returns:
|
|
1096
1131
|
|
|
1097
|
-
|type|description|
|
|
1098
|
-
|
|
1099
|
-
|
|
1132
|
+
| type | description |
|
|
1133
|
+
| ------- | ----------------------------------- |
|
|
1134
|
+
| `Int32` | The amount of 1-bits in its operand |
|
|
1100
1135
|
|
|
1101
1136
|
Examples:
|
|
1102
1137
|
|
|
@@ -1116,28 +1151,28 @@ No other changes yet.
|
|
|
1116
1151
|
</details>
|
|
1117
1152
|
|
|
1118
1153
|
```grain
|
|
1119
|
-
(**)
|
|
1154
|
+
(**): (base: Int32, power: Int32) => Int32
|
|
1120
1155
|
```
|
|
1121
1156
|
|
|
1122
1157
|
Computes the exponentiation of the given base and power.
|
|
1123
1158
|
|
|
1124
1159
|
Parameters:
|
|
1125
1160
|
|
|
1126
|
-
|param|type|description|
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1161
|
+
| param | type | description |
|
|
1162
|
+
| ------- | ------- | ------------------- |
|
|
1163
|
+
| `base` | `Int32` | The base number |
|
|
1164
|
+
| `power` | `Int32` | The exponent number |
|
|
1130
1165
|
|
|
1131
1166
|
Returns:
|
|
1132
1167
|
|
|
1133
|
-
|type|description|
|
|
1134
|
-
|
|
1135
|
-
|
|
1168
|
+
| type | description |
|
|
1169
|
+
| ------- | ---------------------------------- |
|
|
1170
|
+
| `Int32` | The base raised to the given power |
|
|
1136
1171
|
|
|
1137
1172
|
Examples:
|
|
1138
1173
|
|
|
1139
1174
|
```grain
|
|
1140
|
-
|
|
1175
|
+
use Int32.{ (**) }
|
|
1141
1176
|
assert 2l ** 3l == 8l
|
|
1142
1177
|
```
|
|
1143
1178
|
|