Skip to content

Commit

Permalink
update rudi-contrib
Browse files Browse the repository at this point in the history
  • Loading branch information
xrstf committed Dec 28, 2023
1 parent c8ea81a commit fdba4de
Show file tree
Hide file tree
Showing 36 changed files with 286 additions and 9 deletions.
10 changes: 10 additions & 0 deletions cmd/rudi/cmd/console/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,17 @@ You can also request help for any of these functions using `help FUNCTION`:
* `new-key-set` – create a set filled with the keys of an object
* `new-set` – create a set filled with the given values
* `set-delete` – returns a copy of the set with the given values removed from it
* `set-diff` – returns the difference between two sets
* `set-eq?` – returns true if two sets hold the same values
* `set-has-any?` – returns true if the set contains _any_ of the given values
* `set-has?` – returns true if the set contains _all_ of the given values
* `set-insert` – returns a copy of the set with the newly added values inserted to it
* `set-intersection` – returns the insersection of two sets
* `set-list` – returns a sorted vector containing the values of the set
* `set-size` – returns the number of values in the set
* `set-superset-of?` – returns true if the other set is a superset of the base set
* `set-symdiff` – returns the symmetric difference between two sets
* `set-union` – returns the union of two or more sets

* **uuid**
* `uuidv4` – returns a new, randomly generated v4 UUID
Expand Down
Binary file modified cmd/rudi/docs/data/cmd-console.md.gz
Binary file not shown.
Binary file added cmd/rudi/docs/data/functions/new-set.md.gz
Binary file not shown.
Binary file added cmd/rudi/docs/data/functions/set-delete.md.gz
Binary file not shown.
Binary file added cmd/rudi/docs/data/functions/set-diff.md.gz
Binary file not shown.
Binary file added cmd/rudi/docs/data/functions/set-eq.md.gz
Binary file not shown.
Binary file added cmd/rudi/docs/data/functions/set-has-any.md.gz
Binary file not shown.
Binary file added cmd/rudi/docs/data/functions/set-has.md.gz
Binary file not shown.
Binary file added cmd/rudi/docs/data/functions/set-insert.md.gz
Binary file not shown.
Binary file added cmd/rudi/docs/data/functions/set-intersection.md.gz
Binary file not shown.
Binary file added cmd/rudi/docs/data/functions/set-list.md.gz
Binary file not shown.
Binary file added cmd/rudi/docs/data/functions/set-size.md.gz
Binary file not shown.
Binary file added cmd/rudi/docs/data/functions/set-superset-of.md.gz
Binary file not shown.
Binary file added cmd/rudi/docs/data/functions/set-symdiff.md.gz
Binary file not shown.
Binary file added cmd/rudi/docs/data/functions/set-union.md.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion cmd/rudi/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/spf13/pflag v1.0.5
go.xrstf.de/rudi v0.5.1
go.xrstf.de/rudi-contrib/semver v0.1.5
go.xrstf.de/rudi-contrib/set v0.0.2
go.xrstf.de/rudi-contrib/set v0.1.1
go.xrstf.de/rudi-contrib/uuid v0.1.4
go.xrstf.de/rudi-contrib/yaml v0.1.4
gopkg.in/yaml.v3 v3.0.1
Expand Down
4 changes: 2 additions & 2 deletions cmd/rudi/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ github.com/xrstf/colorjson v0.0.0-20231123184920-5ea6fecf578f h1:gVBqsyWwyxxzSGj
github.com/xrstf/colorjson v0.0.0-20231123184920-5ea6fecf578f/go.mod h1:AY6XdslHQYqT5ivYt21gXNpCjsck8iEoytnNfz3COxY=
go.xrstf.de/rudi-contrib/semver v0.1.5 h1:qnp5dfoHk7X7EBuBHGplUfbtfpHcOD9f9zXo+GegErI=
go.xrstf.de/rudi-contrib/semver v0.1.5/go.mod h1:4YieUyLSWXEF0nF3hUW3nydeJr6Hm2QDHdiLizIW97c=
go.xrstf.de/rudi-contrib/set v0.0.2 h1:bsx9YBrCwGBRDOP3n2Tx01z1ugu2eGQoMd4gLrcx9IU=
go.xrstf.de/rudi-contrib/set v0.0.2/go.mod h1:sSVG87d5+N3F+q+a83uMsYKityChmbC23fUEUfAEQWU=
go.xrstf.de/rudi-contrib/set v0.1.1 h1:7MBJrZrrAc3a6MjoBzp4/l2BRn94+lrjTDwWKcCHXBY=
go.xrstf.de/rudi-contrib/set v0.1.1/go.mod h1:sSVG87d5+N3F+q+a83uMsYKityChmbC23fUEUfAEQWU=
go.xrstf.de/rudi-contrib/uuid v0.1.4 h1:zYDebdBnAi6lX5ktBrwIK2tuCpJXfGKDqmx6SVcSw0Q=
go.xrstf.de/rudi-contrib/uuid v0.1.4/go.mod h1:3SDmKKKOJUSkwZpbL0zyzNvM+yf20rUwPAn8/5rHBWI=
go.xrstf.de/rudi-contrib/yaml v0.1.4 h1:R8RMSodKUwI/b1f16TWbp2RVFoPAFWRDchBD+aNmBFo=
Expand Down
10 changes: 10 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,17 @@ Rudi function set. They are however all available by default in the `rudi` inter
* [`new-key-set`](extlib/set/new-key-set.md) – create a set filled with the keys of an object
* [`new-set`](extlib/set/new-set.md) – create a set filled with the given values
* [`set-delete`](extlib/set/set-delete.md) – returns a copy of the set with the given values removed from it
* [`set-diff`](extlib/set/set-diff.md) – returns the difference between two sets
* [`set-eq?`](extlib/set/set-eq.md) – returns true if two sets hold the same values
* [`set-has-any?`](extlib/set/set-has-any.md) – returns true if the set contains _any_ of the given values
* [`set-has?`](extlib/set/set-has.md) – returns true if the set contains _all_ of the given values
* [`set-insert`](extlib/set/set-insert.md) – returns a copy of the set with the newly added values inserted to it
* [`set-intersection`](extlib/set/set-intersection.md) – returns the insersection of two sets
* [`set-list`](extlib/set/set-list.md) – returns a sorted vector containing the values of the set
* [`set-size`](extlib/set/set-size.md) – returns the number of values in the set
* [`set-superset-of?`](extlib/set/set-superset-of.md) – returns true if the other set is a superset of the base set
* [`set-symdiff`](extlib/set/set-symdiff.md) – returns the symmetric difference between two sets
* [`set-union`](extlib/set/set-union.md) – returns the union of two or more sets

### uuid

Expand Down
10 changes: 10 additions & 0 deletions docs/extlib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ interpreter is its own Go module and does not contribute to the Rudi language re
* [`new-key-set`](../extlib/set/new-key-set.md) – create a set filled with the keys of an object
* [`new-set`](../extlib/set/new-set.md) – create a set filled with the given values
* [`set-delete`](../extlib/set/set-delete.md) – returns a copy of the set with the given values removed from it
* [`set-diff`](../extlib/set/set-diff.md) – returns the difference between two sets
* [`set-eq?`](../extlib/set/set-eq.md) – returns true if two sets hold the same values
* [`set-has-any?`](../extlib/set/set-has-any.md) – returns true if the set contains _any_ of the given values
* [`set-has?`](../extlib/set/set-has.md) – returns true if the set contains _all_ of the given values
* [`set-insert`](../extlib/set/set-insert.md) – returns a copy of the set with the newly added values inserted to it
* [`set-intersection`](../extlib/set/set-intersection.md) – returns the insersection of two sets
* [`set-list`](../extlib/set/set-list.md) – returns a sorted vector containing the values of the set
* [`set-size`](../extlib/set/set-size.md) – returns the number of values in the set
* [`set-superset-of?`](../extlib/set/set-superset-of.md) – returns true if the other set is a superset of the base set
* [`set-symdiff`](../extlib/set/set-symdiff.md) – returns the symmetric difference between two sets
* [`set-union`](../extlib/set/set-union.md) – returns the union of two or more sets

### uuid

Expand Down
26 changes: 26 additions & 0 deletions docs/extlib/set/new-set.md
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.
20 changes: 20 additions & 0 deletions docs/extlib/set/set-delete.md
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.
18 changes: 18 additions & 0 deletions docs/extlib/set/set-diff.md
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.
19 changes: 19 additions & 0 deletions docs/extlib/set/set-eq.md
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.
21 changes: 21 additions & 0 deletions docs/extlib/set/set-has-any.md
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.
21 changes: 21 additions & 0 deletions docs/extlib/set/set-has.md
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.
21 changes: 21 additions & 0 deletions docs/extlib/set/set-insert.md
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.
17 changes: 17 additions & 0 deletions docs/extlib/set/set-intersection.md
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.
14 changes: 14 additions & 0 deletions docs/extlib/set/set-list.md
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.
14 changes: 14 additions & 0 deletions docs/extlib/set/set-size.md
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.
19 changes: 19 additions & 0 deletions docs/extlib/set/set-superset-of.md
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`.
19 changes: 19 additions & 0 deletions docs/extlib/set/set-symdiff.md
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.
18 changes: 18 additions & 0 deletions docs/extlib/set/set-union.md
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.
2 changes: 1 addition & 1 deletion hack/docs-prerender/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/yuin/goldmark v1.6.0 // indirect
github.com/yuin/goldmark-emoji v1.0.2 // indirect
go.xrstf.de/rudi-contrib/semver v0.1.5 // indirect
go.xrstf.de/rudi-contrib/set v0.0.2 // indirect
go.xrstf.de/rudi-contrib/set v0.1.1 // indirect
go.xrstf.de/rudi-contrib/uuid v0.1.4 // indirect
go.xrstf.de/rudi-contrib/yaml v0.1.4 // indirect
golang.org/x/net v0.17.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions hack/docs-prerender/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ github.com/yuin/goldmark-emoji v1.0.2 h1:c/RgTShNgHTtc6xdz2KKI74jJr6rWi7FPgnP9GA
github.com/yuin/goldmark-emoji v1.0.2/go.mod h1:RhP/RWpexdp+KHs7ghKnifRoIs/Bq4nDS7tRbCkOwKY=
go.xrstf.de/rudi-contrib/semver v0.1.5 h1:qnp5dfoHk7X7EBuBHGplUfbtfpHcOD9f9zXo+GegErI=
go.xrstf.de/rudi-contrib/semver v0.1.5/go.mod h1:4YieUyLSWXEF0nF3hUW3nydeJr6Hm2QDHdiLizIW97c=
go.xrstf.de/rudi-contrib/set v0.0.2 h1:bsx9YBrCwGBRDOP3n2Tx01z1ugu2eGQoMd4gLrcx9IU=
go.xrstf.de/rudi-contrib/set v0.0.2/go.mod h1:sSVG87d5+N3F+q+a83uMsYKityChmbC23fUEUfAEQWU=
go.xrstf.de/rudi-contrib/set v0.1.1 h1:7MBJrZrrAc3a6MjoBzp4/l2BRn94+lrjTDwWKcCHXBY=
go.xrstf.de/rudi-contrib/set v0.1.1/go.mod h1:sSVG87d5+N3F+q+a83uMsYKityChmbC23fUEUfAEQWU=
go.xrstf.de/rudi-contrib/uuid v0.1.4 h1:zYDebdBnAi6lX5ktBrwIK2tuCpJXfGKDqmx6SVcSw0Q=
go.xrstf.de/rudi-contrib/uuid v0.1.4/go.mod h1:3SDmKKKOJUSkwZpbL0zyzNvM+yf20rUwPAn8/5rHBWI=
go.xrstf.de/rudi-contrib/yaml v0.1.4 h1:R8RMSodKUwI/b1f16TWbp2RVFoPAFWRDchBD+aNmBFo=
Expand Down
2 changes: 1 addition & 1 deletion hack/docs-toc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/muesli/termenv v0.15.2 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
go.xrstf.de/rudi-contrib/semver v0.1.5 // indirect
go.xrstf.de/rudi-contrib/set v0.0.2 // indirect
go.xrstf.de/rudi-contrib/set v0.1.1 // indirect
go.xrstf.de/rudi-contrib/uuid v0.1.4 // indirect
go.xrstf.de/rudi-contrib/yaml v0.1.4 // indirect
golang.org/x/sys v0.14.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions hack/docs-toc/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
go.xrstf.de/rudi-contrib/semver v0.1.5 h1:qnp5dfoHk7X7EBuBHGplUfbtfpHcOD9f9zXo+GegErI=
go.xrstf.de/rudi-contrib/semver v0.1.5/go.mod h1:4YieUyLSWXEF0nF3hUW3nydeJr6Hm2QDHdiLizIW97c=
go.xrstf.de/rudi-contrib/set v0.0.2 h1:bsx9YBrCwGBRDOP3n2Tx01z1ugu2eGQoMd4gLrcx9IU=
go.xrstf.de/rudi-contrib/set v0.0.2/go.mod h1:sSVG87d5+N3F+q+a83uMsYKityChmbC23fUEUfAEQWU=
go.xrstf.de/rudi-contrib/set v0.1.1 h1:7MBJrZrrAc3a6MjoBzp4/l2BRn94+lrjTDwWKcCHXBY=
go.xrstf.de/rudi-contrib/set v0.1.1/go.mod h1:sSVG87d5+N3F+q+a83uMsYKityChmbC23fUEUfAEQWU=
go.xrstf.de/rudi-contrib/uuid v0.1.4 h1:zYDebdBnAi6lX5ktBrwIK2tuCpJXfGKDqmx6SVcSw0Q=
go.xrstf.de/rudi-contrib/uuid v0.1.4/go.mod h1:3SDmKKKOJUSkwZpbL0zyzNvM+yf20rUwPAn8/5rHBWI=
go.xrstf.de/rudi-contrib/yaml v0.1.4 h1:R8RMSodKUwI/b1f16TWbp2RVFoPAFWRDchBD+aNmBFo=
Expand Down

0 comments on commit fdba4de

Please sign in to comment.