Previous: , Up: one-dimension   [Index]

### 33.5 Operations

#### Set operations

Function: %range-intersection type range-a range-b

Return a range representing the intersection of the argument ranges. It does not matter which range has start less than the other.

Intersection is a closed operation on the space of ranges: The intersection of two ranges is a range (possibly empty). If the ranges are not overlapping return `#f` to represent the empty range.

Function: %range-union type range-a range-b

Return two values representing the union of the argument ranges. It does not matter which range has start less than the other.

Union is not a closed operation on the space of ranges: The union of two contiguous or overlapping ranges is a single range, but the union of two disjoint ranges is the set holding the two argument ranges.

If the argument ranges are disjoint and non–contiguous: Return two values being range-a and range-b. If the argument ranges are contiguous or overlapping: Return two values being `#f` and a new range representing the union.

This function should be called like this:

```(let-values (((head tail) (%range-union type r-a r-b)))
(when tail ---))
```
Function: %range-difference type range-a range-b

Return two values representing the difference between the argument ranges; the difference is the set of elements present in one range and not in the other. It does not matter which range has start less than the other.

Difference is not a closed operation on the space of ranges: In genreral the result is a couple of ranges. The first one represents values which are all less than the values in the second one. Both the returned values can be `#f`.

This function should be called like this:

```(let-values (((head tail) (%range-difference type r-a r-b)))
(when tail ---))
```
Function: %range-in-first-only type range-a range-b

Return two values representing the elements of range-a that are not in range-b.

This operation is not a closed operation on the space of ranges: In genreral the result is a couple of ranges. The first one represents values which are all less than the values in the second one. Both the returned values can be `#f`.

This function should be called like this:

```(let-values (((head tail) (%range-in-first-only type r-a r-b)))
(when tail ---))
```
Function: %domain-intersection type domain-a domain-b

Return a new domain representing the intersection of the arguments. The intersection is the set of values present in both the arguments.

The returned value may share some structure with the arguments.

Function: %domain-union type domain-a domain-b

Return a new domain representing the union of the arguments. The union is the set of values present in one and/or the other argument.

The returned value may share some structure with the arguments.

Function: %domain-difference type domain-a domain-b

Return a new domain representing the difference of the arguments. The difference is the set of values present in one or the other argument.

The returned value may share some structure with the arguments.

Function: %domain-complement type domain domain-universe

Return a new domain representing the complement of domain in the space defined by domain-universe. The returned value holds all the items from domain-universe that are not in domain.

The returned value may share some structure with the arguments.

#### List operations

Function: %range-for-each type proc range

Apply proc to each value in the range.

Function: %range-every type proc range

Apply proc to each value in the range and return true if all the return values are true. The application stops at the first `#f` return value.

Function: %range-any type proc range

Apply proc to each value in the range and return true if at least one of the returned values is true. The application stops at the first true return value.

Function: %range-fold type kons knil range

Fold kons over the values in the range.

Function: %range->list type range

Return a list holding all the elements in the range.

Function: %domain-for-each type proc domain

Apply proc to each element of domain.

Function: %domain-every type proc domain

Apply proc to each value in the domain and return true if all the return values are true. The application stops at the first `#f` return value.

Function: %domain-any type proc domain

Apply proc to each value in the domain and return true if at least one of the returned values is true. The application stops at the first true return value.

Function: %domain-fold type kons knil domain

Fold kons over the values in the domain.

Function: %domain->list type domain

Return a list holding all the elements in the domain.

#### Miscellaneous operations

Function: %range-concatenate type range-a range-b

Concatenate the ranges and return the resulting range. It does not matter which range has start less than the other. It makes sense to apply this function to ranges that satisfy `%range-contiguous?`.

The returned range may share some value with the original ranges.

Previous: , Up: one-dimension   [Index]