@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.
- package/CHANGELOG.md +193 -0
- package/LICENSE +1 -1
- package/README.md +25 -2
- package/array.gr +1512 -199
- package/array.md +2032 -94
- package/bigint.gr +239 -140
- package/bigint.md +450 -106
- package/buffer.gr +595 -102
- package/buffer.md +903 -145
- package/bytes.gr +401 -110
- package/bytes.md +551 -63
- package/char.gr +228 -49
- package/char.md +373 -7
- package/exception.gr +26 -12
- package/exception.md +29 -5
- package/float32.gr +130 -109
- package/float32.md +185 -57
- package/float64.gr +112 -99
- package/float64.md +185 -57
- package/hash.gr +47 -37
- package/hash.md +21 -3
- package/int16.gr +430 -0
- package/int16.md +618 -0
- package/int32.gr +200 -269
- package/int32.md +254 -289
- package/int64.gr +142 -225
- package/int64.md +254 -289
- package/int8.gr +511 -0
- package/int8.md +786 -0
- package/json.gr +2084 -0
- package/json.md +608 -0
- package/list.gr +120 -68
- package/list.md +125 -80
- package/map.gr +560 -57
- package/map.md +672 -56
- package/marshal.gr +239 -227
- package/marshal.md +36 -4
- package/number.gr +626 -676
- package/number.md +738 -153
- package/option.gr +33 -35
- package/option.md +58 -42
- package/package.json +2 -2
- package/path.gr +148 -187
- package/path.md +47 -96
- package/pervasives.gr +75 -416
- package/pervasives.md +85 -180
- package/priorityqueue.gr +433 -74
- package/priorityqueue.md +422 -54
- package/queue.gr +362 -80
- package/queue.md +433 -38
- package/random.gr +67 -75
- package/random.md +68 -40
- package/range.gr +135 -63
- package/range.md +198 -43
- package/rational.gr +284 -0
- package/rational.md +545 -0
- package/regex.gr +933 -1066
- package/regex.md +59 -60
- package/result.gr +23 -25
- package/result.md +54 -39
- package/runtime/atof/common.gr +78 -82
- package/runtime/atof/common.md +22 -10
- package/runtime/atof/decimal.gr +102 -127
- package/runtime/atof/decimal.md +28 -7
- package/runtime/atof/lemire.gr +56 -71
- package/runtime/atof/lemire.md +9 -1
- package/runtime/atof/parse.gr +83 -110
- package/runtime/atof/parse.md +12 -2
- package/runtime/atof/slow.gr +28 -35
- package/runtime/atof/slow.md +9 -1
- package/runtime/atof/table.gr +19 -18
- package/runtime/atof/table.md +10 -2
- package/runtime/atoi/parse.gr +153 -136
- package/runtime/atoi/parse.md +50 -1
- package/runtime/bigint.gr +410 -517
- package/runtime/bigint.md +71 -57
- package/runtime/compare.gr +176 -85
- package/runtime/compare.md +31 -1
- package/runtime/dataStructures.gr +144 -32
- package/runtime/dataStructures.md +267 -31
- package/runtime/debugPrint.gr +34 -15
- package/runtime/debugPrint.md +37 -5
- package/runtime/equal.gr +53 -52
- package/runtime/equal.md +30 -1
- package/runtime/exception.gr +38 -47
- package/runtime/exception.md +10 -8
- package/runtime/gc.gr +23 -152
- package/runtime/gc.md +13 -17
- package/runtime/malloc.gr +31 -31
- package/runtime/malloc.md +11 -3
- package/runtime/numberUtils.gr +191 -172
- package/runtime/numberUtils.md +17 -9
- package/runtime/numbers.gr +1695 -1021
- package/runtime/numbers.md +1098 -134
- package/runtime/string.gr +540 -242
- package/runtime/string.md +76 -6
- package/runtime/unsafe/constants.gr +30 -13
- package/runtime/unsafe/constants.md +80 -0
- package/runtime/unsafe/conv.gr +55 -28
- package/runtime/unsafe/conv.md +41 -9
- package/runtime/unsafe/memory.gr +10 -30
- package/runtime/unsafe/memory.md +15 -19
- package/runtime/unsafe/tags.gr +37 -21
- package/runtime/unsafe/tags.md +88 -8
- package/runtime/unsafe/wasmf32.gr +30 -36
- package/runtime/unsafe/wasmf32.md +64 -56
- package/runtime/unsafe/wasmf64.gr +30 -36
- package/runtime/unsafe/wasmf64.md +64 -56
- package/runtime/unsafe/wasmi32.gr +49 -66
- package/runtime/unsafe/wasmi32.md +102 -94
- package/runtime/unsafe/wasmi64.gr +52 -79
- package/runtime/unsafe/wasmi64.md +108 -100
- package/runtime/utils/printing.gr +13 -15
- package/runtime/utils/printing.md +11 -3
- package/runtime/wasi.gr +294 -295
- package/runtime/wasi.md +62 -42
- package/set.gr +574 -64
- package/set.md +634 -54
- package/stack.gr +181 -64
- package/stack.md +271 -42
- package/string.gr +453 -533
- package/string.md +241 -151
- package/uint16.gr +369 -0
- package/uint16.md +585 -0
- package/uint32.gr +470 -0
- package/uint32.md +737 -0
- package/uint64.gr +471 -0
- package/uint64.md +737 -0
- package/uint8.gr +369 -0
- package/uint8.md +585 -0
- package/uri.gr +1093 -0
- package/uri.md +477 -0
- package/{sys → wasi}/file.gr +914 -500
- package/{sys → wasi}/file.md +454 -50
- package/wasi/process.gr +292 -0
- package/{sys → wasi}/process.md +164 -6
- package/wasi/random.gr +77 -0
- package/wasi/random.md +80 -0
- package/{sys → wasi}/time.gr +15 -22
- package/{sys → wasi}/time.md +5 -5
- package/immutablearray.gr +0 -929
- package/immutablearray.md +0 -1038
- package/immutablemap.gr +0 -493
- package/immutablemap.md +0 -479
- package/immutablepriorityqueue.gr +0 -360
- package/immutablepriorityqueue.md +0 -291
- package/immutableset.gr +0 -498
- package/immutableset.md +0 -449
- package/runtime/debug.gr +0 -2
- package/runtime/debug.md +0 -6
- package/runtime/unsafe/errors.gr +0 -36
- package/runtime/unsafe/errors.md +0 -204
- package/sys/process.gr +0 -254
- package/sys/random.gr +0 -79
- package/sys/random.md +0 -66
package/set.md
CHANGED
|
@@ -4,13 +4,15 @@ title: Set
|
|
|
4
4
|
|
|
5
5
|
A Set is an unordered collection of unique values. Operations on a Set mutate the internal state, so it never needs to be re-assigned.
|
|
6
6
|
|
|
7
|
+
An immutable set implementation is available in the `Immutable` submodule.
|
|
8
|
+
|
|
7
9
|
<details disabled>
|
|
8
10
|
<summary tabindex="-1">Added in <code>0.3.0</code></summary>
|
|
9
11
|
No other changes yet.
|
|
10
12
|
</details>
|
|
11
13
|
|
|
12
14
|
```grain
|
|
13
|
-
|
|
15
|
+
from "set" include Set
|
|
14
16
|
```
|
|
15
17
|
|
|
16
18
|
## Types
|
|
@@ -23,28 +25,49 @@ Type declarations included in the Set module.
|
|
|
23
25
|
type Set<k>
|
|
24
26
|
```
|
|
25
27
|
|
|
28
|
+
### Set.**InternalSetStats**
|
|
29
|
+
|
|
30
|
+
```grain
|
|
31
|
+
record InternalSetStats {
|
|
32
|
+
currentSize: Number,
|
|
33
|
+
bucketCount: Number,
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Represents the internal state of a set.
|
|
38
|
+
|
|
26
39
|
## Values
|
|
27
40
|
|
|
28
|
-
Functions
|
|
41
|
+
Functions and constants included in the Set module.
|
|
29
42
|
|
|
30
|
-
### Set.**
|
|
43
|
+
### Set.**make**
|
|
31
44
|
|
|
32
|
-
<details
|
|
33
|
-
<summary
|
|
34
|
-
|
|
45
|
+
<details>
|
|
46
|
+
<summary>Added in <code>0.3.0</code></summary>
|
|
47
|
+
<table>
|
|
48
|
+
<thead>
|
|
49
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
50
|
+
</thead>
|
|
51
|
+
<tbody>
|
|
52
|
+
<tr><td><code>0.6.0</code></td><td>Merged with `makeSized`; modified signature to accept size</td></tr>
|
|
53
|
+
</tbody>
|
|
54
|
+
</table>
|
|
35
55
|
</details>
|
|
36
56
|
|
|
37
57
|
```grain
|
|
38
|
-
|
|
58
|
+
make : (?size: Number) => Set<a>
|
|
39
59
|
```
|
|
40
60
|
|
|
41
|
-
Creates a new empty set with an initial storage of the given size. As
|
|
61
|
+
Creates a new empty set with an initial storage of the given size. As
|
|
62
|
+
values are added or removed, the internal storage may grow or shrink.
|
|
63
|
+
Generally, you won't need to care about the storage size of your set and
|
|
64
|
+
can use the default size.
|
|
42
65
|
|
|
43
66
|
Parameters:
|
|
44
67
|
|
|
45
68
|
|param|type|description|
|
|
46
69
|
|-----|----|-----------|
|
|
47
|
-
|
|
70
|
+
|`?size`|`Number`|The initial storage size of the set|
|
|
48
71
|
|
|
49
72
|
Returns:
|
|
50
73
|
|
|
@@ -52,25 +75,6 @@ Returns:
|
|
|
52
75
|
|----|-----------|
|
|
53
76
|
|`Set<a>`|An empty set with the given initial storage size|
|
|
54
77
|
|
|
55
|
-
### Set.**make**
|
|
56
|
-
|
|
57
|
-
<details disabled>
|
|
58
|
-
<summary tabindex="-1">Added in <code>0.3.0</code></summary>
|
|
59
|
-
No other changes yet.
|
|
60
|
-
</details>
|
|
61
|
-
|
|
62
|
-
```grain
|
|
63
|
-
make : () -> Set<a>
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
Creates a new, empty set.
|
|
67
|
-
|
|
68
|
-
Returns:
|
|
69
|
-
|
|
70
|
-
|type|description|
|
|
71
|
-
|----|-----------|
|
|
72
|
-
|`Set<a>`|An empty set|
|
|
73
|
-
|
|
74
78
|
### Set.**add**
|
|
75
79
|
|
|
76
80
|
<details disabled>
|
|
@@ -79,7 +83,7 @@ No other changes yet.
|
|
|
79
83
|
</details>
|
|
80
84
|
|
|
81
85
|
```grain
|
|
82
|
-
add : (a, Set<a>)
|
|
86
|
+
add : (key: a, set: Set<a>) => Void
|
|
83
87
|
```
|
|
84
88
|
|
|
85
89
|
Adds a new value to the set. If the value already exists, nothing happens.
|
|
@@ -99,7 +103,7 @@ No other changes yet.
|
|
|
99
103
|
</details>
|
|
100
104
|
|
|
101
105
|
```grain
|
|
102
|
-
contains : (a, Set<a>)
|
|
106
|
+
contains : (key: a, set: Set<a>) => Bool
|
|
103
107
|
```
|
|
104
108
|
|
|
105
109
|
Determines if the set contains the given value.
|
|
@@ -125,7 +129,7 @@ No other changes yet.
|
|
|
125
129
|
</details>
|
|
126
130
|
|
|
127
131
|
```grain
|
|
128
|
-
remove : (a, Set<a>)
|
|
132
|
+
remove : (key: a, set: Set<a>) => Void
|
|
129
133
|
```
|
|
130
134
|
|
|
131
135
|
Removes the given value from the set. If the value doesn't exist, nothing happens.
|
|
@@ -145,7 +149,7 @@ No other changes yet.
|
|
|
145
149
|
</details>
|
|
146
150
|
|
|
147
151
|
```grain
|
|
148
|
-
size : Set<a>
|
|
152
|
+
size : (set: Set<a>) => Number
|
|
149
153
|
```
|
|
150
154
|
|
|
151
155
|
Provides the count of values within the set.
|
|
@@ -170,7 +174,7 @@ No other changes yet.
|
|
|
170
174
|
</details>
|
|
171
175
|
|
|
172
176
|
```grain
|
|
173
|
-
isEmpty : Set<a>
|
|
177
|
+
isEmpty : (set: Set<a>) => Bool
|
|
174
178
|
```
|
|
175
179
|
|
|
176
180
|
Determines if the set contains no elements.
|
|
@@ -195,7 +199,7 @@ No other changes yet.
|
|
|
195
199
|
</details>
|
|
196
200
|
|
|
197
201
|
```grain
|
|
198
|
-
clear : Set<a>
|
|
202
|
+
clear : (set: Set<a>) => Void
|
|
199
203
|
```
|
|
200
204
|
|
|
201
205
|
Resets the set by removing all values.
|
|
@@ -221,7 +225,7 @@ Parameters:
|
|
|
221
225
|
</details>
|
|
222
226
|
|
|
223
227
|
```grain
|
|
224
|
-
forEach : ((a
|
|
228
|
+
forEach : (fn: (a => Void), set: Set<a>) => Void
|
|
225
229
|
```
|
|
226
230
|
|
|
227
231
|
Iterates the set, calling an iterator function on each element.
|
|
@@ -230,7 +234,7 @@ Parameters:
|
|
|
230
234
|
|
|
231
235
|
|param|type|description|
|
|
232
236
|
|-----|----|-----------|
|
|
233
|
-
|`fn`|`a
|
|
237
|
+
|`fn`|`a => Void`|The iterator function to call with each element|
|
|
234
238
|
|`set`|`Set<a>`|The set to iterate|
|
|
235
239
|
|
|
236
240
|
### Set.**reduce**
|
|
@@ -241,7 +245,7 @@ No other changes yet.
|
|
|
241
245
|
</details>
|
|
242
246
|
|
|
243
247
|
```grain
|
|
244
|
-
reduce : (((a, b)
|
|
248
|
+
reduce : (fn: ((a, b) => a), init: a, set: Set<b>) => a
|
|
245
249
|
```
|
|
246
250
|
|
|
247
251
|
Combines all elements of a set using a reducer function.
|
|
@@ -250,7 +254,7 @@ Parameters:
|
|
|
250
254
|
|
|
251
255
|
|param|type|description|
|
|
252
256
|
|-----|----|-----------|
|
|
253
|
-
|`fn`|`(a, b)
|
|
257
|
+
|`fn`|`(a, b) => a`|The reducer function to call on each element, where the value returned will be the next accumulator value|
|
|
254
258
|
|`init`|`a`|The initial value to use for the accumulator on the first iteration|
|
|
255
259
|
|`set`|`Set<b>`|The set to iterate|
|
|
256
260
|
|
|
@@ -268,7 +272,7 @@ No other changes yet.
|
|
|
268
272
|
</details>
|
|
269
273
|
|
|
270
274
|
```grain
|
|
271
|
-
filter : ((a
|
|
275
|
+
filter : (fn: (a => Bool), set: Set<a>) => Void
|
|
272
276
|
```
|
|
273
277
|
|
|
274
278
|
Removes elements from a set where a predicate function returns `false`.
|
|
@@ -277,7 +281,7 @@ Parameters:
|
|
|
277
281
|
|
|
278
282
|
|param|type|description|
|
|
279
283
|
|-----|----|-----------|
|
|
280
|
-
|`fn`|`a
|
|
284
|
+
|`fn`|`a => Bool`|The predicate function to indicate which elements to remove from the set, where returning `false` indicates the value should be removed|
|
|
281
285
|
|`set`|`Set<a>`|The set to iterate|
|
|
282
286
|
|
|
283
287
|
### Set.**reject**
|
|
@@ -288,7 +292,7 @@ No other changes yet.
|
|
|
288
292
|
</details>
|
|
289
293
|
|
|
290
294
|
```grain
|
|
291
|
-
reject : ((a
|
|
295
|
+
reject : (fn: (a => Bool), set: Set<a>) => Void
|
|
292
296
|
```
|
|
293
297
|
|
|
294
298
|
Removes elements from a set where a predicate function returns `true`.
|
|
@@ -297,7 +301,7 @@ Parameters:
|
|
|
297
301
|
|
|
298
302
|
|param|type|description|
|
|
299
303
|
|-----|----|-----------|
|
|
300
|
-
|`fn`|`a
|
|
304
|
+
|`fn`|`a => Bool`|The predicate function to indicate which elements to remove from the set, where returning `true` indicates the value should be removed|
|
|
301
305
|
|`set`|`Set<a>`|The set to iterate|
|
|
302
306
|
|
|
303
307
|
### Set.**toList**
|
|
@@ -308,7 +312,7 @@ No other changes yet.
|
|
|
308
312
|
</details>
|
|
309
313
|
|
|
310
314
|
```grain
|
|
311
|
-
toList : Set<a>
|
|
315
|
+
toList : (set: Set<a>) => List<a>
|
|
312
316
|
```
|
|
313
317
|
|
|
314
318
|
Converts a set into a list of its elements.
|
|
@@ -333,7 +337,7 @@ No other changes yet.
|
|
|
333
337
|
</details>
|
|
334
338
|
|
|
335
339
|
```grain
|
|
336
|
-
fromList : List<a>
|
|
340
|
+
fromList : (list: List<a>) => Set<a>
|
|
337
341
|
```
|
|
338
342
|
|
|
339
343
|
Creates a set from a list.
|
|
@@ -358,7 +362,7 @@ No other changes yet.
|
|
|
358
362
|
</details>
|
|
359
363
|
|
|
360
364
|
```grain
|
|
361
|
-
toArray : Set<a>
|
|
365
|
+
toArray : (set: Set<a>) => Array<a>
|
|
362
366
|
```
|
|
363
367
|
|
|
364
368
|
Converts a set into an array of its elements.
|
|
@@ -383,7 +387,7 @@ No other changes yet.
|
|
|
383
387
|
</details>
|
|
384
388
|
|
|
385
389
|
```grain
|
|
386
|
-
fromArray : Array<a>
|
|
390
|
+
fromArray : (array: Array<a>) => Set<a>
|
|
387
391
|
```
|
|
388
392
|
|
|
389
393
|
Creates a set from an array.
|
|
@@ -408,7 +412,7 @@ No other changes yet.
|
|
|
408
412
|
</details>
|
|
409
413
|
|
|
410
414
|
```grain
|
|
411
|
-
union : (Set<a>, Set<a>)
|
|
415
|
+
union : (set1: Set<a>, set2: Set<a>) => Set<a>
|
|
412
416
|
```
|
|
413
417
|
|
|
414
418
|
Combines two sets into a single set containing all elements from both sets.
|
|
@@ -434,7 +438,7 @@ No other changes yet.
|
|
|
434
438
|
</details>
|
|
435
439
|
|
|
436
440
|
```grain
|
|
437
|
-
diff : (Set<a>, Set<a>)
|
|
441
|
+
diff : (set1: Set<a>, set2: Set<a>) => Set<a>
|
|
438
442
|
```
|
|
439
443
|
|
|
440
444
|
Combines two sets into a single set containing only the elements not shared between both sets.
|
|
@@ -460,7 +464,7 @@ No other changes yet.
|
|
|
460
464
|
</details>
|
|
461
465
|
|
|
462
466
|
```grain
|
|
463
|
-
intersect : (Set<a>, Set<a>)
|
|
467
|
+
intersect : (set1: Set<a>, set2: Set<a>) => Set<a>
|
|
464
468
|
```
|
|
465
469
|
|
|
466
470
|
Combines two sets into a single set containing only the elements shared between both sets.
|
|
@@ -480,13 +484,20 @@ Returns:
|
|
|
480
484
|
|
|
481
485
|
### Set.**getInternalStats**
|
|
482
486
|
|
|
483
|
-
<details
|
|
484
|
-
<summary
|
|
485
|
-
|
|
487
|
+
<details>
|
|
488
|
+
<summary>Added in <code>0.3.0</code></summary>
|
|
489
|
+
<table>
|
|
490
|
+
<thead>
|
|
491
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
492
|
+
</thead>
|
|
493
|
+
<tbody>
|
|
494
|
+
<tr><td><code>0.6.0</code></td><td>Return `InternalSetStats` record instead of a tuple</td></tr>
|
|
495
|
+
</tbody>
|
|
496
|
+
</table>
|
|
486
497
|
</details>
|
|
487
498
|
|
|
488
499
|
```grain
|
|
489
|
-
getInternalStats : Set<a>
|
|
500
|
+
getInternalStats : (set: Set<a>) => InternalSetStats
|
|
490
501
|
```
|
|
491
502
|
|
|
492
503
|
Provides data representing the internal state state of the set.
|
|
@@ -501,5 +512,574 @@ Returns:
|
|
|
501
512
|
|
|
502
513
|
|type|description|
|
|
503
514
|
|----|-----------|
|
|
504
|
-
|`
|
|
515
|
+
|`InternalSetStats`|The internal state of the set|
|
|
516
|
+
|
|
517
|
+
## Set.Immutable
|
|
518
|
+
|
|
519
|
+
An immutable set implementation.
|
|
520
|
+
|
|
521
|
+
<details>
|
|
522
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
523
|
+
<table>
|
|
524
|
+
<thead>
|
|
525
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
526
|
+
</thead>
|
|
527
|
+
<tbody>
|
|
528
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
|
|
529
|
+
</tbody>
|
|
530
|
+
</table>
|
|
531
|
+
</details>
|
|
532
|
+
|
|
533
|
+
### Types
|
|
534
|
+
|
|
535
|
+
Type declarations included in the Set.Immutable module.
|
|
536
|
+
|
|
537
|
+
#### Set.Immutable.**Set**
|
|
538
|
+
|
|
539
|
+
```grain
|
|
540
|
+
type Set<a>
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
### Values
|
|
544
|
+
|
|
545
|
+
Functions and constants included in the Set.Immutable module.
|
|
546
|
+
|
|
547
|
+
#### Set.Immutable.**empty**
|
|
548
|
+
|
|
549
|
+
<details>
|
|
550
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
551
|
+
<table>
|
|
552
|
+
<thead>
|
|
553
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
554
|
+
</thead>
|
|
555
|
+
<tbody>
|
|
556
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
|
|
557
|
+
</tbody>
|
|
558
|
+
</table>
|
|
559
|
+
</details>
|
|
560
|
+
|
|
561
|
+
```grain
|
|
562
|
+
empty : Set<a>
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
An empty set
|
|
566
|
+
|
|
567
|
+
#### Set.Immutable.**size**
|
|
568
|
+
|
|
569
|
+
<details>
|
|
570
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
571
|
+
<table>
|
|
572
|
+
<thead>
|
|
573
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
574
|
+
</thead>
|
|
575
|
+
<tbody>
|
|
576
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
|
|
577
|
+
</tbody>
|
|
578
|
+
</table>
|
|
579
|
+
</details>
|
|
580
|
+
|
|
581
|
+
```grain
|
|
582
|
+
size : (set: Set<a>) => Number
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
Provides the count of values within the set.
|
|
586
|
+
|
|
587
|
+
Parameters:
|
|
588
|
+
|
|
589
|
+
|param|type|description|
|
|
590
|
+
|-----|----|-----------|
|
|
591
|
+
|`set`|`Set<a>`|The set to inspect|
|
|
592
|
+
|
|
593
|
+
Returns:
|
|
594
|
+
|
|
595
|
+
|type|description|
|
|
596
|
+
|----|-----------|
|
|
597
|
+
|`Number`|The count of elements in the set|
|
|
598
|
+
|
|
599
|
+
#### Set.Immutable.**isEmpty**
|
|
600
|
+
|
|
601
|
+
<details>
|
|
602
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
603
|
+
<table>
|
|
604
|
+
<thead>
|
|
605
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
606
|
+
</thead>
|
|
607
|
+
<tbody>
|
|
608
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
|
|
609
|
+
</tbody>
|
|
610
|
+
</table>
|
|
611
|
+
</details>
|
|
612
|
+
|
|
613
|
+
```grain
|
|
614
|
+
isEmpty : (set: Set<a>) => Bool
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
Determines if the set contains no elements.
|
|
618
|
+
|
|
619
|
+
Parameters:
|
|
620
|
+
|
|
621
|
+
|param|type|description|
|
|
622
|
+
|-----|----|-----------|
|
|
623
|
+
|`set`|`Set<a>`|The set to inspect|
|
|
624
|
+
|
|
625
|
+
Returns:
|
|
626
|
+
|
|
627
|
+
|type|description|
|
|
628
|
+
|----|-----------|
|
|
629
|
+
|`Bool`|`true` if the given set is empty or `false` otherwise|
|
|
630
|
+
|
|
631
|
+
#### Set.Immutable.**add**
|
|
632
|
+
|
|
633
|
+
<details>
|
|
634
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
635
|
+
<table>
|
|
636
|
+
<thead>
|
|
637
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
638
|
+
</thead>
|
|
639
|
+
<tbody>
|
|
640
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
|
|
641
|
+
</tbody>
|
|
642
|
+
</table>
|
|
643
|
+
</details>
|
|
644
|
+
|
|
645
|
+
```grain
|
|
646
|
+
add : (key: a, set: Set<a>) => Set<a>
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
Produces a new set by inserting the given value into the set. If the value
|
|
650
|
+
already exists, the new set will have the same elements as the input set.
|
|
651
|
+
|
|
652
|
+
Parameters:
|
|
653
|
+
|
|
654
|
+
|param|type|description|
|
|
655
|
+
|-----|----|-----------|
|
|
656
|
+
|`key`|`a`|The value to add|
|
|
657
|
+
|`set`|`Set<a>`|The base set|
|
|
658
|
+
|
|
659
|
+
Returns:
|
|
660
|
+
|
|
661
|
+
|type|description|
|
|
662
|
+
|----|-----------|
|
|
663
|
+
|`Set<a>`|A new set containing the new element|
|
|
664
|
+
|
|
665
|
+
#### Set.Immutable.**contains**
|
|
666
|
+
|
|
667
|
+
<details>
|
|
668
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
669
|
+
<table>
|
|
670
|
+
<thead>
|
|
671
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
672
|
+
</thead>
|
|
673
|
+
<tbody>
|
|
674
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
|
|
675
|
+
</tbody>
|
|
676
|
+
</table>
|
|
677
|
+
</details>
|
|
678
|
+
|
|
679
|
+
```grain
|
|
680
|
+
contains : (key: a, set: Set<a>) => Bool
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
Determines if the set contains the given value.
|
|
684
|
+
|
|
685
|
+
Parameters:
|
|
686
|
+
|
|
687
|
+
|param|type|description|
|
|
688
|
+
|-----|----|-----------|
|
|
689
|
+
|`key`|`a`|The value to search for|
|
|
690
|
+
|`set`|`Set<a>`|The set to search|
|
|
691
|
+
|
|
692
|
+
Returns:
|
|
693
|
+
|
|
694
|
+
|type|description|
|
|
695
|
+
|----|-----------|
|
|
696
|
+
|`Bool`|`true` if the set contains the given value or `false` otherwise|
|
|
697
|
+
|
|
698
|
+
#### Set.Immutable.**remove**
|
|
699
|
+
|
|
700
|
+
<details>
|
|
701
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
702
|
+
<table>
|
|
703
|
+
<thead>
|
|
704
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
705
|
+
</thead>
|
|
706
|
+
<tbody>
|
|
707
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
|
|
708
|
+
</tbody>
|
|
709
|
+
</table>
|
|
710
|
+
</details>
|
|
711
|
+
|
|
712
|
+
```grain
|
|
713
|
+
remove : (key: a, set: Set<a>) => Set<a>
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
Produces a new set without the given element. If the value doesn't exist in
|
|
717
|
+
the set, the set will be returned unmodified.
|
|
718
|
+
|
|
719
|
+
Parameters:
|
|
720
|
+
|
|
721
|
+
|param|type|description|
|
|
722
|
+
|-----|----|-----------|
|
|
723
|
+
|`key`|`a`|The value to exclude|
|
|
724
|
+
|`set`|`Set<a>`|The set to exclude from|
|
|
725
|
+
|
|
726
|
+
Returns:
|
|
727
|
+
|
|
728
|
+
|type|description|
|
|
729
|
+
|----|-----------|
|
|
730
|
+
|`Set<a>`|A new set without the excluded element|
|
|
731
|
+
|
|
732
|
+
#### Set.Immutable.**forEach**
|
|
733
|
+
|
|
734
|
+
<details>
|
|
735
|
+
<summary>Added in <code>0.6.0</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>Originally in `"immutableset"` module</td></tr>
|
|
742
|
+
</tbody>
|
|
743
|
+
</table>
|
|
744
|
+
</details>
|
|
745
|
+
|
|
746
|
+
```grain
|
|
747
|
+
forEach : (fn: (a => Void), set: Set<a>) => Void
|
|
748
|
+
```
|
|
749
|
+
|
|
750
|
+
Iterates the set, calling an iterator function on each element.
|
|
751
|
+
|
|
752
|
+
Parameters:
|
|
753
|
+
|
|
754
|
+
|param|type|description|
|
|
755
|
+
|-----|----|-----------|
|
|
756
|
+
|`fn`|`a => Void`|The iterator function to call with each element|
|
|
757
|
+
|`set`|`Set<a>`|The set to iterate|
|
|
758
|
+
|
|
759
|
+
#### Set.Immutable.**reduce**
|
|
760
|
+
|
|
761
|
+
<details>
|
|
762
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
763
|
+
<table>
|
|
764
|
+
<thead>
|
|
765
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
766
|
+
</thead>
|
|
767
|
+
<tbody>
|
|
768
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
|
|
769
|
+
</tbody>
|
|
770
|
+
</table>
|
|
771
|
+
</details>
|
|
772
|
+
|
|
773
|
+
```grain
|
|
774
|
+
reduce : (fn: ((a, b) => a), init: a, set: Set<b>) => a
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
Combines all elements of a set using a reducer function.
|
|
778
|
+
|
|
779
|
+
Parameters:
|
|
780
|
+
|
|
781
|
+
|param|type|description|
|
|
782
|
+
|-----|----|-----------|
|
|
783
|
+
|`fn`|`(a, b) => a`|The reducer function to call on each element, where the value returned will be the next accumulator value|
|
|
784
|
+
|`init`|`a`|The initial value to use for the accumulator on the first iteration|
|
|
785
|
+
|`set`|`Set<b>`|The set to iterate|
|
|
786
|
+
|
|
787
|
+
Returns:
|
|
788
|
+
|
|
789
|
+
|type|description|
|
|
790
|
+
|----|-----------|
|
|
791
|
+
|`a`|The final accumulator returned from `fn`|
|
|
792
|
+
|
|
793
|
+
#### Set.Immutable.**filter**
|
|
794
|
+
|
|
795
|
+
<details>
|
|
796
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
797
|
+
<table>
|
|
798
|
+
<thead>
|
|
799
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
800
|
+
</thead>
|
|
801
|
+
<tbody>
|
|
802
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
|
|
803
|
+
</tbody>
|
|
804
|
+
</table>
|
|
805
|
+
</details>
|
|
806
|
+
|
|
807
|
+
```grain
|
|
808
|
+
filter : (fn: (a => Bool), set: Set<a>) => Set<a>
|
|
809
|
+
```
|
|
810
|
+
|
|
811
|
+
Produces a new set without the elements from the input set where a predicate function returns `false`.
|
|
812
|
+
|
|
813
|
+
Parameters:
|
|
814
|
+
|
|
815
|
+
|param|type|description|
|
|
816
|
+
|-----|----|-----------|
|
|
817
|
+
|`fn`|`a => Bool`|The predicate function to indicate which elements to exclude from the set, where returning `false` indicates the value should be excluded|
|
|
818
|
+
|`set`|`Set<a>`|The set to iterate|
|
|
819
|
+
|
|
820
|
+
Returns:
|
|
821
|
+
|
|
822
|
+
|type|description|
|
|
823
|
+
|----|-----------|
|
|
824
|
+
|`Set<a>`|A new set excluding the elements not fulfilling the predicate|
|
|
825
|
+
|
|
826
|
+
#### Set.Immutable.**reject**
|
|
827
|
+
|
|
828
|
+
<details>
|
|
829
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
830
|
+
<table>
|
|
831
|
+
<thead>
|
|
832
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
833
|
+
</thead>
|
|
834
|
+
<tbody>
|
|
835
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
|
|
836
|
+
</tbody>
|
|
837
|
+
</table>
|
|
838
|
+
</details>
|
|
839
|
+
|
|
840
|
+
```grain
|
|
841
|
+
reject : (fn: (a => Bool), set: Set<a>) => Set<a>
|
|
842
|
+
```
|
|
843
|
+
|
|
844
|
+
Produces a new set without the elements from the input set where a predicate function returns `true`.
|
|
845
|
+
|
|
846
|
+
Parameters:
|
|
847
|
+
|
|
848
|
+
|param|type|description|
|
|
849
|
+
|-----|----|-----------|
|
|
850
|
+
|`fn`|`a => Bool`|The predicate function to indicate which elements to exclude from the set, where returning `true` indicates the value should be excluded|
|
|
851
|
+
|`set`|`Set<a>`|The set to iterate|
|
|
852
|
+
|
|
853
|
+
Returns:
|
|
854
|
+
|
|
855
|
+
|type|description|
|
|
856
|
+
|----|-----------|
|
|
857
|
+
|`Set<a>`|A new set excluding the elements fulfilling the predicate|
|
|
858
|
+
|
|
859
|
+
#### Set.Immutable.**union**
|
|
860
|
+
|
|
861
|
+
<details>
|
|
862
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
863
|
+
<table>
|
|
864
|
+
<thead>
|
|
865
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
866
|
+
</thead>
|
|
867
|
+
<tbody>
|
|
868
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
|
|
869
|
+
</tbody>
|
|
870
|
+
</table>
|
|
871
|
+
</details>
|
|
872
|
+
|
|
873
|
+
```grain
|
|
874
|
+
union : (set1: Set<a>, set2: Set<a>) => Set<a>
|
|
875
|
+
```
|
|
876
|
+
|
|
877
|
+
Combines two sets into a single set containing all elements from both sets.
|
|
878
|
+
|
|
879
|
+
Parameters:
|
|
880
|
+
|
|
881
|
+
|param|type|description|
|
|
882
|
+
|-----|----|-----------|
|
|
883
|
+
|`set1`|`Set<a>`|The first set to combine|
|
|
884
|
+
|`set2`|`Set<a>`|The second set to combine|
|
|
885
|
+
|
|
886
|
+
Returns:
|
|
887
|
+
|
|
888
|
+
|type|description|
|
|
889
|
+
|----|-----------|
|
|
890
|
+
|`Set<a>`|A set containing all elements of both sets|
|
|
891
|
+
|
|
892
|
+
#### Set.Immutable.**diff**
|
|
893
|
+
|
|
894
|
+
<details>
|
|
895
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
896
|
+
<table>
|
|
897
|
+
<thead>
|
|
898
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
899
|
+
</thead>
|
|
900
|
+
<tbody>
|
|
901
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
|
|
902
|
+
</tbody>
|
|
903
|
+
</table>
|
|
904
|
+
</details>
|
|
905
|
+
|
|
906
|
+
```grain
|
|
907
|
+
diff : (set1: Set<a>, set2: Set<a>) => Set<a>
|
|
908
|
+
```
|
|
909
|
+
|
|
910
|
+
Combines two sets into a single set containing only the elements not shared between both sets.
|
|
911
|
+
|
|
912
|
+
Parameters:
|
|
913
|
+
|
|
914
|
+
|param|type|description|
|
|
915
|
+
|-----|----|-----------|
|
|
916
|
+
|`set1`|`Set<a>`|The first set to combine|
|
|
917
|
+
|`set2`|`Set<a>`|The second set to combine|
|
|
918
|
+
|
|
919
|
+
Returns:
|
|
920
|
+
|
|
921
|
+
|type|description|
|
|
922
|
+
|----|-----------|
|
|
923
|
+
|`Set<a>`|A set containing only unshared elements from both sets|
|
|
924
|
+
|
|
925
|
+
#### Set.Immutable.**intersect**
|
|
926
|
+
|
|
927
|
+
<details>
|
|
928
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
929
|
+
<table>
|
|
930
|
+
<thead>
|
|
931
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
932
|
+
</thead>
|
|
933
|
+
<tbody>
|
|
934
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
|
|
935
|
+
</tbody>
|
|
936
|
+
</table>
|
|
937
|
+
</details>
|
|
938
|
+
|
|
939
|
+
```grain
|
|
940
|
+
intersect : (set1: Set<a>, set2: Set<a>) => Set<a>
|
|
941
|
+
```
|
|
942
|
+
|
|
943
|
+
Combines two sets into a single set containing only the elements shared between both sets.
|
|
944
|
+
|
|
945
|
+
Parameters:
|
|
946
|
+
|
|
947
|
+
|param|type|description|
|
|
948
|
+
|-----|----|-----------|
|
|
949
|
+
|`set1`|`Set<a>`|The first set to combine|
|
|
950
|
+
|`set2`|`Set<a>`|The second set to combine|
|
|
951
|
+
|
|
952
|
+
Returns:
|
|
953
|
+
|
|
954
|
+
|type|description|
|
|
955
|
+
|----|-----------|
|
|
956
|
+
|`Set<a>`|A set containing only shared elements from both sets|
|
|
957
|
+
|
|
958
|
+
#### Set.Immutable.**fromList**
|
|
959
|
+
|
|
960
|
+
<details>
|
|
961
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
962
|
+
<table>
|
|
963
|
+
<thead>
|
|
964
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
965
|
+
</thead>
|
|
966
|
+
<tbody>
|
|
967
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
|
|
968
|
+
</tbody>
|
|
969
|
+
</table>
|
|
970
|
+
</details>
|
|
971
|
+
|
|
972
|
+
```grain
|
|
973
|
+
fromList : (list: List<a>) => Set<a>
|
|
974
|
+
```
|
|
975
|
+
|
|
976
|
+
Creates a set from a list.
|
|
977
|
+
|
|
978
|
+
Parameters:
|
|
979
|
+
|
|
980
|
+
|param|type|description|
|
|
981
|
+
|-----|----|-----------|
|
|
982
|
+
|`list`|`List<a>`|The list to convert|
|
|
983
|
+
|
|
984
|
+
Returns:
|
|
985
|
+
|
|
986
|
+
|type|description|
|
|
987
|
+
|----|-----------|
|
|
988
|
+
|`Set<a>`|A set containing all list values|
|
|
989
|
+
|
|
990
|
+
#### Set.Immutable.**toList**
|
|
991
|
+
|
|
992
|
+
<details>
|
|
993
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
994
|
+
<table>
|
|
995
|
+
<thead>
|
|
996
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
997
|
+
</thead>
|
|
998
|
+
<tbody>
|
|
999
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
|
|
1000
|
+
</tbody>
|
|
1001
|
+
</table>
|
|
1002
|
+
</details>
|
|
1003
|
+
|
|
1004
|
+
```grain
|
|
1005
|
+
toList : (set: Set<a>) => List<a>
|
|
1006
|
+
```
|
|
1007
|
+
|
|
1008
|
+
Converts a set into a list of its elements.
|
|
1009
|
+
|
|
1010
|
+
Parameters:
|
|
1011
|
+
|
|
1012
|
+
|param|type|description|
|
|
1013
|
+
|-----|----|-----------|
|
|
1014
|
+
|`set`|`Set<a>`|The set to convert|
|
|
1015
|
+
|
|
1016
|
+
Returns:
|
|
1017
|
+
|
|
1018
|
+
|type|description|
|
|
1019
|
+
|----|-----------|
|
|
1020
|
+
|`List<a>`|A list containing all set values|
|
|
1021
|
+
|
|
1022
|
+
#### Set.Immutable.**fromArray**
|
|
1023
|
+
|
|
1024
|
+
<details>
|
|
1025
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
1026
|
+
<table>
|
|
1027
|
+
<thead>
|
|
1028
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
1029
|
+
</thead>
|
|
1030
|
+
<tbody>
|
|
1031
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
|
|
1032
|
+
</tbody>
|
|
1033
|
+
</table>
|
|
1034
|
+
</details>
|
|
1035
|
+
|
|
1036
|
+
```grain
|
|
1037
|
+
fromArray : (array: Array<a>) => Set<a>
|
|
1038
|
+
```
|
|
1039
|
+
|
|
1040
|
+
Creates a set from an array.
|
|
1041
|
+
|
|
1042
|
+
Parameters:
|
|
1043
|
+
|
|
1044
|
+
|param|type|description|
|
|
1045
|
+
|-----|----|-----------|
|
|
1046
|
+
|`array`|`Array<a>`|The array to convert|
|
|
1047
|
+
|
|
1048
|
+
Returns:
|
|
1049
|
+
|
|
1050
|
+
|type|description|
|
|
1051
|
+
|----|-----------|
|
|
1052
|
+
|`Set<a>`|A set containing all array values|
|
|
1053
|
+
|
|
1054
|
+
#### Set.Immutable.**toArray**
|
|
1055
|
+
|
|
1056
|
+
<details>
|
|
1057
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
1058
|
+
<table>
|
|
1059
|
+
<thead>
|
|
1060
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
1061
|
+
</thead>
|
|
1062
|
+
<tbody>
|
|
1063
|
+
<tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
|
|
1064
|
+
</tbody>
|
|
1065
|
+
</table>
|
|
1066
|
+
</details>
|
|
1067
|
+
|
|
1068
|
+
```grain
|
|
1069
|
+
toArray : (set: Set<a>) => Array<a>
|
|
1070
|
+
```
|
|
1071
|
+
|
|
1072
|
+
Converts a set into an array of its elements.
|
|
1073
|
+
|
|
1074
|
+
Parameters:
|
|
1075
|
+
|
|
1076
|
+
|param|type|description|
|
|
1077
|
+
|-----|----|-----------|
|
|
1078
|
+
|`set`|`Set<a>`|The set to convert|
|
|
1079
|
+
|
|
1080
|
+
Returns:
|
|
1081
|
+
|
|
1082
|
+
|type|description|
|
|
1083
|
+
|----|-----------|
|
|
1084
|
+
|`Array<a>`|An array containing all set values|
|
|
505
1085
|
|