From 0a3ad8ba914ab42ebbb88a3d955f71d71d581fc1 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 5 Mar 2025 00:21:30 -0500 Subject: Alphabetize and index functions --- docs/sets.md | 169 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 89 insertions(+), 80 deletions(-) (limited to 'docs/sets.md') diff --git a/docs/sets.md b/docs/sets.md index e9c44b29..83e5cd92 100644 --- a/docs/sets.md +++ b/docs/sets.md @@ -75,31 +75,17 @@ iterating over any of the new values. ## Set Methods -### `has` - -**Description:** -Checks if the set contains a specified item. - -**Signature:** -```tomo -func has(set:{T}, item:T -> Bool) -``` - -**Parameters:** - -- `set`: The set to check. -- `item`: The item to check for presence. - -**Returns:** -`yes` if the item is present, `no` otherwise. - -**Example:** -```tomo ->> {10, 20}:has(20) -= yes -``` - ---- +- [`func add(set:{T}, item: T -> Void)`](#`add) +- [`func add_all(set:@{T}, items: [T] -> Void)`](#`add_all) +- [`func clear(set:@{T} -> Void)`](#`clear) +- [`func has(set:{T}, item:T -> Bool)`](#`has) +- [`func (set: {T}, other: {T}, strict: Bool = no -> Bool)`](#`is_subset_of) +- [`func is_superset_of(set:{T}, other: {T}, strict: Bool = no -> Bool)`](#`is_superset_of) +- [`func overlap(set:{T}, other: {T} -> {T})`](#`overlap) +- [`func remove(set:@{T}, item: T -> Void)`](#`remove) +- [`func remove_all(set:@{T}, items: [T] -> Void)`](#`remove_all) +- [`func with(set:{T}, other: {T} -> {T})`](#`with) +- [`func without(set:{T}, other: {T} -> {T})`](#`without) ### `add` @@ -151,106 +137,107 @@ Nothing. --- -### `remove` +### `clear` **Description:** -Removes an item from the set. +Removes all items from the set. **Signature:** ```tomo -func remove(set:@{T}, item: T -> Void) +func clear(set:@{T} -> Void) ``` **Parameters:** - `set`: The mutable reference to the set. -- `item`: The item to remove from the set. **Returns:** Nothing. **Example:** ```tomo ->> nums:remove(42) +>> nums:clear() ``` --- -### `remove_all` +### `has` **Description:** -Removes multiple items from the set. +Checks if the set contains a specified item. **Signature:** ```tomo -func remove_all(set:@{T}, items: [T] -> Void) +func has(set:{T}, item:T -> Bool) ``` **Parameters:** -- `set`: The mutable reference to the set. -- `items`: The array of items to remove from the set. +- `set`: The set to check. +- `item`: The item to check for presence. **Returns:** -Nothing. +`yes` if the item is present, `no` otherwise. **Example:** ```tomo ->> nums:remove_all([1, 2, 3]) +>> {10, 20}:has(20) += yes ``` --- -### `clear` +### `is_subset_of` **Description:** -Removes all items from the set. +Checks if the set is a subset of another set. **Signature:** ```tomo -func clear(set:@{T} -> Void) +func (set: {T}, other: {T}, strict: Bool = no -> Bool) ``` **Parameters:** -- `set`: The mutable reference to the set. +- `set`: The set to check. +- `other`: The set to compare against. +- `strict`: If `yes`, checks if the set is a strict subset (does not equal the other set). **Returns:** -Nothing. +`yes` if the set is a subset of the other set (strictly or not), `no` otherwise. **Example:** ```tomo ->> nums:clear() +>> {1, 2}:is_subset_of({1, 2, 3}) += yes ``` --- -### `with` +### `is_superset_of` **Description:** -Creates a new set that is the union of the original set and another set. +Checks if the set is a superset of another set. **Signature:** ```tomo -func with(set:{T}, other: {T} -> {T}) +func is_superset_of(set:{T}, other: {T}, strict: Bool = no -> Bool) ``` **Parameters:** -- `set`: The original set. -- `other`: The set to union with. +- `set`: The set to check. +- `other`: The set to compare against. +- `strict`: If `yes`, checks if the set is a strict superset (does not equal the other set). **Returns:** -A new set containing all items from both sets. +`yes` if the set is a superset of the other set (strictly or not), `no` otherwise. **Example:** ```tomo ->> {1, 2}:with({2, 3}) -= {1, 2, 3} +>> {1, 2, 3}:is_superset_of({1, 2}) += yes ``` - ---- - ### `overlap` **Description:** @@ -277,80 +264,102 @@ A new set containing only items present in both sets. --- -### `without` +### `remove` **Description:** -Creates a new set with items from the original set but without items from another set. +Removes an item from the set. **Signature:** ```tomo -func without(set:{T}, other: {T} -> {T}) +func remove(set:@{T}, item: T -> Void) ``` **Parameters:** -- `set`: The original set. -- `other`: The set of items to remove from the original set. +- `set`: The mutable reference to the set. +- `item`: The item to remove from the set. **Returns:** -A new set containing items from the original set excluding those in the other set. +Nothing. **Example:** ```tomo ->> {1, 2}:without({2, 3}) -= {1} +>> nums:remove(42) ``` --- -### `is_subset_of` +### `remove_all` **Description:** -Checks if the set is a subset of another set. +Removes multiple items from the set. **Signature:** ```tomo -func (set: {T}, other: {T}, strict: Bool = no -> Bool) +func remove_all(set:@{T}, items: [T] -> Void) ``` **Parameters:** -- `set`: The set to check. -- `other`: The set to compare against. -- `strict`: If `yes`, checks if the set is a strict subset (does not equal the other set). +- `set`: The mutable reference to the set. +- `items`: The array of items to remove from the set. **Returns:** -`yes` if the set is a subset of the other set (strictly or not), `no` otherwise. +Nothing. **Example:** ```tomo ->> {1, 2}:is_subset_of({1, 2, 3}) -= yes +>> nums:remove_all([1, 2, 3]) ``` --- -### `is_superset_of` +### `with` **Description:** -Checks if the set is a superset of another set. +Creates a new set that is the union of the original set and another set. **Signature:** ```tomo -func is_superset_of(set:{T}, other: {T}, strict: Bool = no -> Bool) +func with(set:{T}, other: {T} -> {T}) ``` **Parameters:** -- `set`: The set to check. -- `other`: The set to compare against. -- `strict`: If `yes`, checks if the set is a strict superset (does not equal the other set). +- `set`: The original set. +- `other`: The set to union with. **Returns:** -`yes` if the set is a superset of the other set (strictly or not), `no` otherwise. +A new set containing all items from both sets. **Example:** ```tomo ->> {1, 2, 3}:is_superset_of({1, 2}) -= yes +>> {1, 2}:with({2, 3}) += {1, 2, 3} +``` + +--- + +### `without` + +**Description:** +Creates a new set with items from the original set but without items from another set. + +**Signature:** +```tomo +func without(set:{T}, other: {T} -> {T}) +``` + +**Parameters:** + +- `set`: The original set. +- `other`: The set of items to remove from the original set. + +**Returns:** +A new set containing items from the original set excluding those in the other set. + +**Example:** +```tomo +>> {1, 2}:without({2, 3}) += {1} ``` -- cgit v1.2.3