mech-set 0.3.4

Set library for the Mech language
Documentation
set/slice
===============================================================================

%% Take an ordered slice of a set by index range

1. Usage
-------------------------------------------------------------------------------

```mech:disabled
S := set/slice(A, start, count)
```

2. Description
-------------------------------------------------------------------------------

Creates an ordered, contiguous view of elements from set A.  
The slice starts at index `start` and spans `count` elements, or fewer if the end
would go past the last element. The result preserves the original order from A.

This wraps the Rust **IndexSet::slice** type. The slice supports indexed operations
like an array, but it is not a hashed set and does not perform set lookups.

3. Input
-------------------------------------------------------------------------------

Arguments:
- A : set of T, the input set
- start : integer, zero based index where the slice begins
- count : integer, maximum number of elements in the slice

Element type constraints:
- T can be any value stored in the set. No extra traits are required beyond what A already uses.

4. Output
-------------------------------------------------------------------------------

Result:
- S : slice view of T values in order. In Mech this is exposed as an array with the
  selected elements in their original order.

5. Examples
-------------------------------------------------------------------------------

(5.1) Basic slice

```mech:ex1
A := {"a", "b", "c", "d", "e"}
S := set/slice(A, 1, 3)
```

(5.2) Slice to end when count exceeds remaining

```mech:ex2
A := {10, 20, 30, 40}
S := set/slice(A, 2, 10)
```

(5.3) Empty slice

```mech:ex3
A := {"x", "y"}
S := set/slice(A, 2, 5)
```

6. Details
-------------------------------------------------------------------------------

Order and equality:
- The slice considers order in comparisons. Two slices are equal only if they have the
  same elements in the same order.
- Slices also support ordering comparisons and hashing based on order.

Not a set:
- The slice is an ordered view. It does not support hashed operations like membership
  tests by value in constant time. Use the original set for hashed lookups.

Indexing rules:
- start must be between 0 and `len(A)`.
- count may be zero.
- If `start + count > len(A)`, the slice stops at the end of A.

Performance:
- Creating a slice is cheap and does not re hash elements. Access is by index.

7. Errors
-------------------------------------------------------------------------------

- Incorrect number of arguments (expects three).
- start is out of bounds or negative.
- count is negative.