@grain/stdlib 0.5.2 → 0.5.4
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 +59 -0
- package/array.gr +61 -1
- package/array.md +113 -0
- package/bigint.md +30 -30
- package/buffer.gr +24 -22
- package/char.gr +2 -2
- package/float32.md +3 -3
- package/float64.md +3 -3
- package/immutablemap.gr +493 -0
- package/immutablemap.md +479 -0
- package/immutablepriorityqueue.gr +360 -0
- package/immutablepriorityqueue.md +291 -0
- package/immutableset.gr +498 -0
- package/immutableset.md +449 -0
- package/list.gr +75 -2
- package/list.md +110 -0
- package/map.gr +1 -2
- package/marshal.gr +1058 -0
- package/marshal.md +76 -0
- package/number.gr +689 -23
- package/number.md +362 -27
- package/package.json +1 -1
- package/pervasives.gr +16 -5
- package/pervasives.md +28 -0
- package/priorityqueue.gr +261 -0
- package/priorityqueue.md +309 -0
- package/queue.gr +14 -1
- package/queue.md +16 -1
- package/regex.gr +90 -67
- package/runtime/bigint.gr +4 -4
- package/runtime/compare.gr +179 -0
- package/runtime/compare.md +6 -0
- package/runtime/equal.gr +3 -3
- package/runtime/exception.gr +9 -5
- package/runtime/exception.md +8 -2
- package/runtime/gc.gr +2 -1
- package/runtime/malloc.gr +1 -3
- package/runtime/numberUtils.gr +11 -11
- package/runtime/numbers.gr +423 -100
- package/runtime/numbers.md +50 -0
- package/runtime/string.gr +4 -2
- package/set.gr +26 -27
- package/stack.gr +12 -0
- package/stack.md +15 -0
- package/string.gr +409 -53
- package/string.md +164 -1
- package/sys/file.gr +4 -4
- package/sys/file.md +3 -3
- package/sys/process.gr +3 -3
- package/sys/process.md +3 -3
- package/sys/random.gr +2 -2
- package/sys/random.md +2 -2
- package/sys/time.gr +2 -2
- package/sys/time.md +2 -2
package/number.md
CHANGED
|
@@ -17,10 +17,36 @@ import Number from "number"
|
|
|
17
17
|
|
|
18
18
|
Number constant values.
|
|
19
19
|
|
|
20
|
+
### Number.**nan**
|
|
21
|
+
|
|
22
|
+
<details disabled>
|
|
23
|
+
<summary tabindex="-1">Added in <code>0.5.4</code></summary>
|
|
24
|
+
No other changes yet.
|
|
25
|
+
</details>
|
|
26
|
+
|
|
27
|
+
```grain
|
|
28
|
+
nan : Number
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
NaN represented as a Number value.
|
|
32
|
+
|
|
33
|
+
### Number.**infinity**
|
|
34
|
+
|
|
35
|
+
<details disabled>
|
|
36
|
+
<summary tabindex="-1">Added in <code>0.5.4</code></summary>
|
|
37
|
+
No other changes yet.
|
|
38
|
+
</details>
|
|
39
|
+
|
|
40
|
+
```grain
|
|
41
|
+
infinity : Number
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Infinity represented as a Number value.
|
|
45
|
+
|
|
20
46
|
### Number.**pi**
|
|
21
47
|
|
|
22
48
|
<details disabled>
|
|
23
|
-
<summary tabindex="-1">Added in <code>
|
|
49
|
+
<summary tabindex="-1">Added in <code>0.5.2</code></summary>
|
|
24
50
|
No other changes yet.
|
|
25
51
|
</details>
|
|
26
52
|
|
|
@@ -33,7 +59,7 @@ Pi represented as a Number value.
|
|
|
33
59
|
### Number.**tau**
|
|
34
60
|
|
|
35
61
|
<details disabled>
|
|
36
|
-
<summary tabindex="-1">Added in <code>
|
|
62
|
+
<summary tabindex="-1">Added in <code>0.5.2</code></summary>
|
|
37
63
|
No other changes yet.
|
|
38
64
|
</details>
|
|
39
65
|
|
|
@@ -46,7 +72,7 @@ Tau represented as a Number value.
|
|
|
46
72
|
### Number.**e**
|
|
47
73
|
|
|
48
74
|
<details disabled>
|
|
49
|
-
<summary tabindex="-1">Added in <code>
|
|
75
|
+
<summary tabindex="-1">Added in <code>0.5.2</code></summary>
|
|
50
76
|
No other changes yet.
|
|
51
77
|
</details>
|
|
52
78
|
|
|
@@ -164,6 +190,57 @@ Returns:
|
|
|
164
190
|
|----|-----------|
|
|
165
191
|
|`Number`|The quotient of the two operands|
|
|
166
192
|
|
|
193
|
+
### Number.**pow**
|
|
194
|
+
|
|
195
|
+
<details disabled>
|
|
196
|
+
<summary tabindex="-1">Added in <code>0.5.4</code></summary>
|
|
197
|
+
No other changes yet.
|
|
198
|
+
</details>
|
|
199
|
+
|
|
200
|
+
```grain
|
|
201
|
+
pow : (Number, Number) -> Number
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Computes the exponentiation of the given base and power.
|
|
205
|
+
|
|
206
|
+
Parameters:
|
|
207
|
+
|
|
208
|
+
|param|type|description|
|
|
209
|
+
|-----|----|-----------|
|
|
210
|
+
|`base`|`Number`|The base number|
|
|
211
|
+
|`power`|`Number`|The exponent number|
|
|
212
|
+
|
|
213
|
+
Returns:
|
|
214
|
+
|
|
215
|
+
|type|description|
|
|
216
|
+
|----|-----------|
|
|
217
|
+
|`Number`|The base raised to the given power|
|
|
218
|
+
|
|
219
|
+
### Number.**exp**
|
|
220
|
+
|
|
221
|
+
<details disabled>
|
|
222
|
+
<summary tabindex="-1">Added in <code>0.5.4</code></summary>
|
|
223
|
+
No other changes yet.
|
|
224
|
+
</details>
|
|
225
|
+
|
|
226
|
+
```grain
|
|
227
|
+
exp : Number -> Number
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Computes the exponentiation of Euler's number to the given power.
|
|
231
|
+
|
|
232
|
+
Parameters:
|
|
233
|
+
|
|
234
|
+
|param|type|description|
|
|
235
|
+
|-----|----|-----------|
|
|
236
|
+
|`power`|`Number`|The exponent number|
|
|
237
|
+
|
|
238
|
+
Returns:
|
|
239
|
+
|
|
240
|
+
|type|description|
|
|
241
|
+
|----|-----------|
|
|
242
|
+
|`Number`|The `Number.e` value raised to the given power|
|
|
243
|
+
|
|
167
244
|
### Number.**sqrt**
|
|
168
245
|
|
|
169
246
|
<details disabled>
|
|
@@ -225,9 +302,16 @@ Number.sign(0) == 0
|
|
|
225
302
|
|
|
226
303
|
### Number.**min**
|
|
227
304
|
|
|
228
|
-
<details
|
|
229
|
-
<summary
|
|
230
|
-
|
|
305
|
+
<details>
|
|
306
|
+
<summary>Added in <code>0.4.0</code></summary>
|
|
307
|
+
<table>
|
|
308
|
+
<thead>
|
|
309
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
310
|
+
</thead>
|
|
311
|
+
<tbody>
|
|
312
|
+
<tr><td><code>0.5.4</code></td><td>Handle NaN properly</td></tr>
|
|
313
|
+
</tbody>
|
|
314
|
+
</table>
|
|
231
315
|
</details>
|
|
232
316
|
|
|
233
317
|
```grain
|
|
@@ -251,9 +335,16 @@ Returns:
|
|
|
251
335
|
|
|
252
336
|
### Number.**max**
|
|
253
337
|
|
|
254
|
-
<details
|
|
255
|
-
<summary
|
|
256
|
-
|
|
338
|
+
<details>
|
|
339
|
+
<summary>Added in <code>0.4.0</code></summary>
|
|
340
|
+
<table>
|
|
341
|
+
<thead>
|
|
342
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
343
|
+
</thead>
|
|
344
|
+
<tbody>
|
|
345
|
+
<tr><td><code>0.5.4</code></td><td>Handle NaN properly</td></tr>
|
|
346
|
+
</tbody>
|
|
347
|
+
</table>
|
|
257
348
|
</details>
|
|
258
349
|
|
|
259
350
|
```grain
|
|
@@ -277,9 +368,16 @@ Returns:
|
|
|
277
368
|
|
|
278
369
|
### Number.**ceil**
|
|
279
370
|
|
|
280
|
-
<details
|
|
281
|
-
<summary
|
|
282
|
-
|
|
371
|
+
<details>
|
|
372
|
+
<summary>Added in <code>0.4.0</code></summary>
|
|
373
|
+
<table>
|
|
374
|
+
<thead>
|
|
375
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
376
|
+
</thead>
|
|
377
|
+
<tbody>
|
|
378
|
+
<tr><td><code>0.5.4</code></td><td>Handle NaN and Infinity properly</td></tr>
|
|
379
|
+
</tbody>
|
|
380
|
+
</table>
|
|
283
381
|
</details>
|
|
284
382
|
|
|
285
383
|
```grain
|
|
@@ -302,9 +400,16 @@ Returns:
|
|
|
302
400
|
|
|
303
401
|
### Number.**floor**
|
|
304
402
|
|
|
305
|
-
<details
|
|
306
|
-
<summary
|
|
307
|
-
|
|
403
|
+
<details>
|
|
404
|
+
<summary>Added in <code>0.4.0</code></summary>
|
|
405
|
+
<table>
|
|
406
|
+
<thead>
|
|
407
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
408
|
+
</thead>
|
|
409
|
+
<tbody>
|
|
410
|
+
<tr><td><code>0.5.4</code></td><td>Handle NaN and Infinity properly</td></tr>
|
|
411
|
+
</tbody>
|
|
412
|
+
</table>
|
|
308
413
|
</details>
|
|
309
414
|
|
|
310
415
|
```grain
|
|
@@ -327,9 +432,16 @@ Returns:
|
|
|
327
432
|
|
|
328
433
|
### Number.**trunc**
|
|
329
434
|
|
|
330
|
-
<details
|
|
331
|
-
<summary
|
|
332
|
-
|
|
435
|
+
<details>
|
|
436
|
+
<summary>Added in <code>0.4.0</code></summary>
|
|
437
|
+
<table>
|
|
438
|
+
<thead>
|
|
439
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
440
|
+
</thead>
|
|
441
|
+
<tbody>
|
|
442
|
+
<tr><td><code>0.5.4</code></td><td>Handle NaN and Infinity properly</td></tr>
|
|
443
|
+
</tbody>
|
|
444
|
+
</table>
|
|
333
445
|
</details>
|
|
334
446
|
|
|
335
447
|
```grain
|
|
@@ -352,9 +464,16 @@ Returns:
|
|
|
352
464
|
|
|
353
465
|
### Number.**round**
|
|
354
466
|
|
|
355
|
-
<details
|
|
356
|
-
<summary
|
|
357
|
-
|
|
467
|
+
<details>
|
|
468
|
+
<summary>Added in <code>0.4.0</code></summary>
|
|
469
|
+
<table>
|
|
470
|
+
<thead>
|
|
471
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
472
|
+
</thead>
|
|
473
|
+
<tbody>
|
|
474
|
+
<tr><td><code>0.5.4</code></td><td>Handle NaN and Infinity properly</td></tr>
|
|
475
|
+
</tbody>
|
|
476
|
+
</table>
|
|
358
477
|
</details>
|
|
359
478
|
|
|
360
479
|
```grain
|
|
@@ -425,6 +544,81 @@ Returns:
|
|
|
425
544
|
|----|-----------|
|
|
426
545
|
|`Number`|The negated operand|
|
|
427
546
|
|
|
547
|
+
### Number.**isFloat**
|
|
548
|
+
|
|
549
|
+
<details disabled>
|
|
550
|
+
<summary tabindex="-1">Added in <code>0.5.3</code></summary>
|
|
551
|
+
No other changes yet.
|
|
552
|
+
</details>
|
|
553
|
+
|
|
554
|
+
```grain
|
|
555
|
+
isFloat : Number -> Bool
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
Checks if a number is a floating point value.
|
|
559
|
+
|
|
560
|
+
Parameters:
|
|
561
|
+
|
|
562
|
+
|param|type|description|
|
|
563
|
+
|-----|----|-----------|
|
|
564
|
+
|`x`|`Number`|The number to check|
|
|
565
|
+
|
|
566
|
+
Returns:
|
|
567
|
+
|
|
568
|
+
|type|description|
|
|
569
|
+
|----|-----------|
|
|
570
|
+
|`Bool`|`true` if the value is a floating point number or `false` otherwise|
|
|
571
|
+
|
|
572
|
+
### Number.**isInteger**
|
|
573
|
+
|
|
574
|
+
<details disabled>
|
|
575
|
+
<summary tabindex="-1">Added in <code>0.5.3</code></summary>
|
|
576
|
+
No other changes yet.
|
|
577
|
+
</details>
|
|
578
|
+
|
|
579
|
+
```grain
|
|
580
|
+
isInteger : Number -> Bool
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
Checks if a number is an integer.
|
|
584
|
+
|
|
585
|
+
Parameters:
|
|
586
|
+
|
|
587
|
+
|param|type|description|
|
|
588
|
+
|-----|----|-----------|
|
|
589
|
+
|`x`|`Number`|The number to check|
|
|
590
|
+
|
|
591
|
+
Returns:
|
|
592
|
+
|
|
593
|
+
|type|description|
|
|
594
|
+
|----|-----------|
|
|
595
|
+
|`Bool`|`true` if the value is an integer or `false` otherwise|
|
|
596
|
+
|
|
597
|
+
### Number.**isRational**
|
|
598
|
+
|
|
599
|
+
<details disabled>
|
|
600
|
+
<summary tabindex="-1">Added in <code>0.5.3</code></summary>
|
|
601
|
+
No other changes yet.
|
|
602
|
+
</details>
|
|
603
|
+
|
|
604
|
+
```grain
|
|
605
|
+
isRational : Number -> Bool
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
Checks if a number is a non-integer rational value.
|
|
609
|
+
|
|
610
|
+
Parameters:
|
|
611
|
+
|
|
612
|
+
|param|type|description|
|
|
613
|
+
|-----|----|-----------|
|
|
614
|
+
|`x`|`Number`|The number to check|
|
|
615
|
+
|
|
616
|
+
Returns:
|
|
617
|
+
|
|
618
|
+
|type|description|
|
|
619
|
+
|----|-----------|
|
|
620
|
+
|`Bool`|`true` if the value is a non-integer rational number or `false` otherwise|
|
|
621
|
+
|
|
428
622
|
### Number.**isFinite**
|
|
429
623
|
|
|
430
624
|
<details disabled>
|
|
@@ -537,9 +731,16 @@ Returns:
|
|
|
537
731
|
|
|
538
732
|
### Number.**sin**
|
|
539
733
|
|
|
540
|
-
<details
|
|
541
|
-
<summary
|
|
542
|
-
|
|
734
|
+
<details>
|
|
735
|
+
<summary>Added in <code>0.5.2</code></summary>
|
|
736
|
+
<table>
|
|
737
|
+
<thead>
|
|
738
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
739
|
+
</thead>
|
|
740
|
+
<tbody>
|
|
741
|
+
<tr><td><code>0.5.4</code></td><td>Handle NaN and Infinity</td></tr>
|
|
742
|
+
</tbody>
|
|
743
|
+
</table>
|
|
543
744
|
</details>
|
|
544
745
|
|
|
545
746
|
```grain
|
|
@@ -562,9 +763,16 @@ Returns:
|
|
|
562
763
|
|
|
563
764
|
### Number.**cos**
|
|
564
765
|
|
|
565
|
-
<details
|
|
566
|
-
<summary
|
|
567
|
-
|
|
766
|
+
<details>
|
|
767
|
+
<summary>Added in <code>0.5.2</code></summary>
|
|
768
|
+
<table>
|
|
769
|
+
<thead>
|
|
770
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
771
|
+
</thead>
|
|
772
|
+
<tbody>
|
|
773
|
+
<tr><td><code>0.5.4</code></td><td>Handle NaN and Infinity</td></tr>
|
|
774
|
+
</tbody>
|
|
775
|
+
</table>
|
|
568
776
|
</details>
|
|
569
777
|
|
|
570
778
|
```grain
|
|
@@ -585,3 +793,130 @@ Returns:
|
|
|
585
793
|
|----|-----------|
|
|
586
794
|
|`Number`|The computed cosine|
|
|
587
795
|
|
|
796
|
+
### Number.**tan**
|
|
797
|
+
|
|
798
|
+
<details disabled>
|
|
799
|
+
<summary tabindex="-1">Added in <code>0.5.4</code></summary>
|
|
800
|
+
No other changes yet.
|
|
801
|
+
</details>
|
|
802
|
+
|
|
803
|
+
```grain
|
|
804
|
+
tan : Number -> Number
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
Computes the tangent of a number (in radians) using Chebyshev polynomials.
|
|
808
|
+
|
|
809
|
+
Parameters:
|
|
810
|
+
|
|
811
|
+
|param|type|description|
|
|
812
|
+
|-----|----|-----------|
|
|
813
|
+
|`radians`|`Number`|The input in radians|
|
|
814
|
+
|
|
815
|
+
Returns:
|
|
816
|
+
|
|
817
|
+
|type|description|
|
|
818
|
+
|----|-----------|
|
|
819
|
+
|`Number`|The computed tangent|
|
|
820
|
+
|
|
821
|
+
### Number.**gamma**
|
|
822
|
+
|
|
823
|
+
<details disabled>
|
|
824
|
+
<summary tabindex="-1">Added in <code>0.5.4</code></summary>
|
|
825
|
+
No other changes yet.
|
|
826
|
+
</details>
|
|
827
|
+
|
|
828
|
+
```grain
|
|
829
|
+
gamma : Number -> Number
|
|
830
|
+
```
|
|
831
|
+
|
|
832
|
+
Computes the gamma function of a value using Lanczos approximation.
|
|
833
|
+
Fails when the given value is zero.
|
|
834
|
+
|
|
835
|
+
Parameters:
|
|
836
|
+
|
|
837
|
+
|param|type|description|
|
|
838
|
+
|-----|----|-----------|
|
|
839
|
+
|`z`|`Number`|The value to interpolate|
|
|
840
|
+
|
|
841
|
+
Returns:
|
|
842
|
+
|
|
843
|
+
|type|description|
|
|
844
|
+
|----|-----------|
|
|
845
|
+
|`Number`|The gamma of the given value|
|
|
846
|
+
|
|
847
|
+
### Number.**factorial**
|
|
848
|
+
|
|
849
|
+
<details disabled>
|
|
850
|
+
<summary tabindex="-1">Added in <code>0.5.4</code></summary>
|
|
851
|
+
No other changes yet.
|
|
852
|
+
</details>
|
|
853
|
+
|
|
854
|
+
```grain
|
|
855
|
+
factorial : Number -> Number
|
|
856
|
+
```
|
|
857
|
+
|
|
858
|
+
Computes the product of consecutive integers for an integer input and computes the gamma function for non-integer inputs.
|
|
859
|
+
Fails if the input is a negative number.
|
|
860
|
+
|
|
861
|
+
Parameters:
|
|
862
|
+
|
|
863
|
+
|param|type|description|
|
|
864
|
+
|-----|----|-----------|
|
|
865
|
+
|`n`|`Number`|The value to factorialize|
|
|
866
|
+
|
|
867
|
+
Returns:
|
|
868
|
+
|
|
869
|
+
|type|description|
|
|
870
|
+
|----|-----------|
|
|
871
|
+
|`Number`|The factorial of the given value|
|
|
872
|
+
|
|
873
|
+
### Number.**toRadians**
|
|
874
|
+
|
|
875
|
+
<details disabled>
|
|
876
|
+
<summary tabindex="-1">Added in <code>0.5.4</code></summary>
|
|
877
|
+
No other changes yet.
|
|
878
|
+
</details>
|
|
879
|
+
|
|
880
|
+
```grain
|
|
881
|
+
toRadians : Number -> Number
|
|
882
|
+
```
|
|
883
|
+
|
|
884
|
+
Converts degrees to radians.
|
|
885
|
+
|
|
886
|
+
Parameters:
|
|
887
|
+
|
|
888
|
+
|param|type|description|
|
|
889
|
+
|-----|----|-----------|
|
|
890
|
+
|`degrees`|`Number`|The value to convert|
|
|
891
|
+
|
|
892
|
+
Returns:
|
|
893
|
+
|
|
894
|
+
|type|description|
|
|
895
|
+
|----|-----------|
|
|
896
|
+
|`Number`|The value in radians|
|
|
897
|
+
|
|
898
|
+
### Number.**toDegrees**
|
|
899
|
+
|
|
900
|
+
<details disabled>
|
|
901
|
+
<summary tabindex="-1">Added in <code>0.5.4</code></summary>
|
|
902
|
+
No other changes yet.
|
|
903
|
+
</details>
|
|
904
|
+
|
|
905
|
+
```grain
|
|
906
|
+
toDegrees : Number -> Number
|
|
907
|
+
```
|
|
908
|
+
|
|
909
|
+
Converts radians to degrees.
|
|
910
|
+
|
|
911
|
+
Parameters:
|
|
912
|
+
|
|
913
|
+
|param|type|description|
|
|
914
|
+
|-----|----|-----------|
|
|
915
|
+
|`radians`|`Number`|The value to convert|
|
|
916
|
+
|
|
917
|
+
Returns:
|
|
918
|
+
|
|
919
|
+
|type|description|
|
|
920
|
+
|----|-----------|
|
|
921
|
+
|`Number`|The value in degrees|
|
|
922
|
+
|
package/package.json
CHANGED
package/pervasives.gr
CHANGED
|
@@ -11,6 +11,7 @@ import Memory from "runtime/unsafe/memory"
|
|
|
11
11
|
import WasmI32 from "runtime/unsafe/wasmi32"
|
|
12
12
|
|
|
13
13
|
import { equal as (==) } from "runtime/equal"
|
|
14
|
+
import { compare } from "runtime/compare"
|
|
14
15
|
|
|
15
16
|
import {
|
|
16
17
|
incr,
|
|
@@ -218,6 +219,19 @@ export (<=)
|
|
|
218
219
|
*/
|
|
219
220
|
export (>=)
|
|
220
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Compares the first argument to the second argument and produces an integer result.
|
|
224
|
+
* Provides a consistent ordering over all types and is suitable for sorting and other kinds of ordering.
|
|
225
|
+
* `compare` treats `NaN` differently than the other comparison operators in that it considers `NaN` equal to itself and smaller than any other number.
|
|
226
|
+
*
|
|
227
|
+
* @param num1: The first operand
|
|
228
|
+
* @param num2: The second operand
|
|
229
|
+
* @returns A negative integer if the first operand is less than the second operand, `0` if they are equal, or a positive integer otherwise
|
|
230
|
+
*
|
|
231
|
+
* @since v0.5.3
|
|
232
|
+
*/
|
|
233
|
+
export compare
|
|
234
|
+
|
|
221
235
|
/**
|
|
222
236
|
* @section Math operations: Infix functions for working with Number values.
|
|
223
237
|
*/
|
|
@@ -410,7 +424,7 @@ export (>>)
|
|
|
410
424
|
|
|
411
425
|
// Number coercions & conversions
|
|
412
426
|
|
|
413
|
-
//
|
|
427
|
+
// TODO(#311): Commented until we nail down semantics
|
|
414
428
|
// import foreign wasm convertExactToInexact : Number -> Number as inexact from "stdlib-external/runtime"
|
|
415
429
|
// import foreign wasm convertInexactToExact : Number -> Number as exact from "stdlib-external/runtime"
|
|
416
430
|
|
|
@@ -553,10 +567,7 @@ export primitive unbox: Box<a> -> a = "@unbox"
|
|
|
553
567
|
* @since v0.4.0
|
|
554
568
|
*/
|
|
555
569
|
export let cons = (a, b) =>
|
|
556
|
-
[
|
|
557
|
-
a,
|
|
558
|
-
...b
|
|
559
|
-
] // <- workaround for (grain-lang/grain#802) [TODO] fix #802 and delete
|
|
570
|
+
[a, ...b] // TODO(#802): Remove workaround after 802 is completed
|
|
560
571
|
/**
|
|
561
572
|
* The empty list syntax (`[]`) provided as a value.
|
|
562
573
|
*
|
package/pervasives.md
CHANGED
|
@@ -369,6 +369,34 @@ Returns:
|
|
|
369
369
|
|----|-----------|
|
|
370
370
|
|`Bool`|`true` if the first operand is greater than or equal to the second operand or `false` otherwise|
|
|
371
371
|
|
|
372
|
+
### Pervasives.**compare**
|
|
373
|
+
|
|
374
|
+
<details disabled>
|
|
375
|
+
<summary tabindex="-1">Added in <code>0.5.3</code></summary>
|
|
376
|
+
No other changes yet.
|
|
377
|
+
</details>
|
|
378
|
+
|
|
379
|
+
```grain
|
|
380
|
+
compare : (a, a) -> Number
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
Compares the first argument to the second argument and produces an integer result.
|
|
384
|
+
Provides a consistent ordering over all types and is suitable for sorting and other kinds of ordering.
|
|
385
|
+
`compare` treats `NaN` differently than the other comparison operators in that it considers `NaN` equal to itself and smaller than any other number.
|
|
386
|
+
|
|
387
|
+
Parameters:
|
|
388
|
+
|
|
389
|
+
|param|type|description|
|
|
390
|
+
|-----|----|-----------|
|
|
391
|
+
|`num1`|`a`|The first operand|
|
|
392
|
+
|`num2`|`a`|The second operand|
|
|
393
|
+
|
|
394
|
+
Returns:
|
|
395
|
+
|
|
396
|
+
|type|description|
|
|
397
|
+
|----|-----------|
|
|
398
|
+
|`Number`|A negative integer if the first operand is less than the second operand, `0` if they are equal, or a positive integer otherwise|
|
|
399
|
+
|
|
372
400
|
## Math operations
|
|
373
401
|
|
|
374
402
|
Infix functions for working with Number values.
|