-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
286 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# new-set | ||
|
||
This function returns a new string set containing all the given values. Values | ||
are coalesced to strings, vectors are supported but only one level deep (see | ||
examples). | ||
|
||
## Examples | ||
|
||
* `(new-set)` ➜ `set{}` | ||
* `(new-set "test")` ➜ `set{"test"}` | ||
* `(new-set "a" "b" "c" "b" "A")` ➜ `set{"a", "b", "c", "A"}` | ||
* `(new-set "a" ["b" "c"] "d")` ➜ `set{"a", "b", "c", "d"}` | ||
* `(new-set "a" ["b" "c" ["f"]] "d")` ➜ error | ||
|
||
## Forms | ||
|
||
### `(new-set)` ➜ `set` | ||
|
||
This form returns a new, empty set. | ||
|
||
### `(new-set value:any+)` ➜ `set` | ||
|
||
This form coalesces all values as either string or vector. Vectors are unpacked | ||
to one level deep (i.e. they can contain things that coalesce into a string, but | ||
nothing else). Duplicate values can be given and will simply be dropped from the | ||
set. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# set-delete | ||
|
||
This function removes the given values from the set, returning a new set. For | ||
removing values in-place, using `set-delete!`. Just like when constructing a new | ||
set with `new-set`, values must be either directly coalescable to strings, or | ||
be vectors that contain only strings. | ||
|
||
## Examples | ||
|
||
All of the examples assume that `$set` is a set with `{"a", "b", "c"}`. | ||
|
||
* `(set-delete $set "a")` ➜ `set{"b", "c"}` | ||
* `(set-delete $set "a" ["b" "d"] "")` ➜ `set{"c"}` | ||
|
||
## Forms | ||
|
||
### `(set-delete set:set value:any+)` ➜ `set` | ||
|
||
This form returns a copy of the set, with all the values listed being removed | ||
from the set. Values that do not occur in the set are ignored. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# set-diff | ||
|
||
This function returns the difference between two sets. | ||
|
||
## Examples | ||
|
||
All of the examples assume that `$set` is a set with `{"a", "b", "c"}`. | ||
|
||
* `(set-diff $set (new-set))` ➜ `set{"a", "b", "c"}` | ||
* `(set-diff $set (new-set "b"))` ➜ `set{"a", "c"}` | ||
* `(set-diff $set (new-set "d"))` ➜ `set{"a", "b", "c"}` | ||
|
||
## Forms | ||
|
||
### `(set-diff base:set other:set)` ➜ `set` | ||
|
||
This form returns `base - other`, i.a. a new set that contains all values that | ||
are not part of the `other` set. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# set-eq? | ||
|
||
This function returns true if two sets are identical, i.e. contain the exact | ||
same values. | ||
|
||
## Examples | ||
|
||
All of the examples assume that `$set` is a set with `{"a", "b", "c"}`. | ||
|
||
* `(set-eq? $set (new-set))` ➜ `false` | ||
* `(set-eq? $set (new-set "b"))` ➜ `false` | ||
* `(set-eq? $set (new-set "a" "c" "b"))` ➜ `true` | ||
* `(set-eq? $set (new-set "a" "c" "b" "e"))` ➜ `false` | ||
|
||
## Forms | ||
|
||
### `(set-eq? base:set other:set)` ➜ `bool` | ||
|
||
This form returns true if both sets contain the same values. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# set-has-any? | ||
|
||
This function returns true if at least one of the given values occur in the | ||
given set. See also [`set-has?`](set-has.md) for checking if _all_ of the given | ||
values occur in the set. | ||
|
||
## Examples | ||
|
||
All of the examples assume that `$set` is a set with `{"a", "b", "c"}`. | ||
|
||
* `(set-has-any? $set "")` ➜ `false` | ||
* `(set-has-any? $set "b")` ➜ `true` | ||
* `(set-has-any? $set "b" "c")` ➜ `true` | ||
* `(set-has-any? $set "b" "d")` ➜ `true` | ||
* `(set-has-any? $set "d" ["x" "y"])` ➜ `false` | ||
|
||
## Forms | ||
|
||
### `(set-has-any? base:set value:any+)` ➜ `bool` | ||
|
||
This form returns true if the set contains at least one of the given values. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# set-has? | ||
|
||
This function returns true if all of the given values occur in the given set. | ||
See also [`set-has-any?`](set-has-any.md) for checking if _at least one_ of the | ||
given values occurs in the set. | ||
|
||
## Examples | ||
|
||
All of the examples assume that `$set` is a set with `{"a", "b", "c"}`. | ||
|
||
* `(set-has? $set "")` ➜ `false` | ||
* `(set-has? $set "b")` ➜ `true` | ||
* `(set-has? $set "b" "c")` ➜ `true` | ||
* `(set-has? $set "b" "d")` ➜ `false` | ||
* `(set-has? $set "b" ["a" "c"])` ➜ `true` | ||
|
||
## Forms | ||
|
||
### `(set-has? base:set value:any+)` ➜ `bool` | ||
|
||
This form returns true if the set contains all of the given values. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# set-insert | ||
|
||
This function adds the given values to the set, returning a new set. For | ||
adding values in-place, using `set-insert!`. Just like when constructing a new | ||
set with `new-set`, values must be either directly coalescable to strings, or | ||
be vectors that contain only strings. | ||
|
||
## Examples | ||
|
||
All of the examples assume that `$set` is a set with `{"a", "b", "c"}`. | ||
|
||
* `(set-insert $set "a")` ➜ `set{"a", "b", "c"}` | ||
* `(set-insert $set "d")` ➜ `set{"a", "b", "c", "d"}` | ||
* `(set-insert $set "x" ["y"])` ➜ `set{"a", "b", "c", "x", "y"}` | ||
|
||
## Forms | ||
|
||
### `(set-insert set:set value:any+)` ➜ `set` | ||
|
||
This form returns a copy of the set, with all the values listed being added to | ||
the set. Values that already exist in the set are not duplicated, of course. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# set-intersection | ||
|
||
This function returns the intersection of two sets. | ||
|
||
## Examples | ||
|
||
All of the examples assume that `$set` is a set with `{"a", "b", "c"}`. | ||
|
||
* `(set-intersection $set (new-set))` ➜ `set{}` | ||
* `(set-intersection $set (new-set "b"))` ➜ `set{"b"}` | ||
* `(set-intersection $set (new-set "d"))` ➜ `set{}` | ||
|
||
## Forms | ||
|
||
### `(set-intersection base:set other:set)` ➜ `set` | ||
|
||
This form returns a new set that contains all values that exist in both sets. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# set-list | ||
|
||
This function returns a vector containing all the items in the set in sorted | ||
order. | ||
|
||
## Examples | ||
|
||
* `(set-list (new-set "b" "a" "a" ))` ➜ `["a" "b"]` | ||
|
||
## Forms | ||
|
||
### `(set-list set:set)` ➜ `vector` | ||
|
||
This form returns a vector containing all the items in the set in sorted order. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# set-size | ||
|
||
This function returns the number of values in the given set. | ||
|
||
## Examples | ||
|
||
* `(set-size (new-set "a" "b"))` ➜ `2` | ||
* `(set-size (set-delete (new-set "a") "a"))` ➜ `0` | ||
|
||
## Forms | ||
|
||
### `(set-size set:set)` ➜ `int` | ||
|
||
This form returns the number of values in the set. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# set-superset-of? | ||
|
||
This function returns true if the first set is a superset of the second set, | ||
meaning the first set contains at least all values of the second set. | ||
|
||
## Examples | ||
|
||
All of the examples assume that `$set` is a set with `{"a", "b", "c"}`. | ||
|
||
* `(set-superset-of? (new-set) (new-set))` ➜ `true` | ||
* `(set-superset-of? $set (new-set))` ➜ `true` | ||
* `(set-superset-of? $set (new-set "b"))` ➜ `true` | ||
* `(set-superset-of? $set (new-set "d"))` ➜ `false` | ||
|
||
## Forms | ||
|
||
### `(set-superset-of? base:set other:set)` ➜ `bool` | ||
|
||
This form returns true if `base` is a superset of `other`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# set-symdiff | ||
|
||
This function returns a set of values which are in either of the sets, but not | ||
in their intersection. | ||
|
||
## Examples | ||
|
||
All of the examples assume that `$set` is a set with `{"a", "b", "c"}`. | ||
|
||
* `(set-symdiff $set (new-set))` ➜ `set{"a", "b", "c"}` | ||
* `(set-symdiff $set (new-set "b"))` ➜ `set{"a", "c"}` | ||
* `(set-symdiff $set (new-set "d"))` ➜ `set{"a", "b", "c", "d"}` | ||
|
||
## Forms | ||
|
||
### `(set-symdiff base:set other:set)` ➜ `set` | ||
|
||
This form returns a set of values which are in either of the sets, but not | ||
in their intersection. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# set-union | ||
|
||
This function returns the union of two or more sets. | ||
|
||
## Examples | ||
|
||
All of the examples assume that `$set` is a set with `{"a", "b", "c"}`. | ||
|
||
* `(set-union $set (new-set))` ➜ `set{"a", "b", "c"}` | ||
* `(set-union $set (new-set "b"))` ➜ `set{"a", "b", "c"}` | ||
* `(set-union $set (new-set "d" "e"))` ➜ `set{"a", "b", "c", "d" "e"}` | ||
|
||
## Forms | ||
|
||
### `(set-union base:set other:set+)` ➜ `set` | ||
|
||
This form returns a new set that contains all values that exist in any of the | ||
given sets. More than two sets may be merged into a union at the same time. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters