diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-09-21 15:54:05 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-09-21 15:54:05 -0400 |
| commit | fa3c016ad6e51d9bec120a770a7a7d6b2be75007 (patch) | |
| tree | aae4ac4b0cd3f94d9f74bd0ade176e91d5f72cd7 /docs/sets.md | |
| parent | b58daa1469b36fdc7a8c3441ce33e0a6e6e61e0b (diff) | |
More deprecations of set docs stuff
Diffstat (limited to 'docs/sets.md')
| -rw-r--r-- | docs/sets.md | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/docs/sets.md b/docs/sets.md deleted file mode 100644 index c8d67fc4..00000000 --- a/docs/sets.md +++ /dev/null @@ -1,78 +0,0 @@ -# Sets - -Sets represent an unordered collection of unique elements. These are -implemented using hash tables. - -```tomo -a := |10, 20, 30| -b := |20, 30| ->> a.overlap(b) -= |20| -``` - -## Syntax - -Sets are written using `|...|` vertical pipes with comma-separated items: - -```tomo -nums := |10, 20, 30| -``` - -Empty sets must specify the set type explicitly: - -```tomo -empty : |Int| = || -``` - -For type annotations, a set that holds items with type `T` is written as `|T|`. - -### Comprehensions - -Similar to lists, sets can use comprehensions: - -```tomo -set := |10*i for i in 10| -set2 := |10*i for i in 10 if i mod 2 == 0| -set3 := |-10, 10*i for i in 10| -``` - -## Accessing Items - -Sets internally store their items in a list, which you can access with the -`.items` field. This is a constant-time operation that produces an immutable -view: - -```tomo -set := |10, 20, 30| ->> set.items -= [10, 20, 30] -``` - -## Length - -Set length can be accessed by the `.length` field: - -```tomo ->> |10, 20, 30|.length -= 3 -``` - -## Iteration - -You can iterate over the items in a table like this: - -```tomo -for item in set - ... - -for i, item in set - ... -``` - -Set iteration operates over the value of the set when the loop began, so -modifying the set during iteration is safe and will not result in the loop -iterating over any of the new values. - -# API - -[API documentation](../api/sets.md) |
