This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home. For a version of this page that may be more recent, see IntegerSetsCowan in WG2's repo for R7RS-large.

Integer­Sets­Cowan

cowan
2014-10-20 08:44:53
3history
source

Integer set procedures

The elements of an integer set are non-negative exact integers. The procedures for creating and manipulating integer sets are the same as those for SRFI 113 sets, except that set is replaced by integer-set in their names. However, set-comparator has no equivalent for integer sets, and in integer-set, integer-set-unfold, integer-set-map, and integer-set-copy the comparator argument is omitted.

Although sets subsume integer sets, providing them separately allows for increased implementation efficiency. There are two Chicken eggs that provide integer sets: iset, which is conceptually similar to the integer sets described here; and cis, which uses lists of integer intervals.

Additional integer set procedures

(integer-set-limit integer-set)

Returns the limit of integer-set. This procedure corresponds to set-comparator.

(universal-integer-set limit)

Returns a newly allocated integer set. The possible elements of the set are the exact integers from 0 to limit - 1, where limit is an exact non-negative integer. The set contains all possible elements.

(range->integer-set limit low high)

Returns a newly allocated integer set. The possible elements of the set are the exact integers from 0 to limit - 1, where limit is an exact non-negative integer. The set contains the elements from low (inclusive) to high (exclusive).

(integer-set-adjoin-range integer-set low high)

Returns a newly allocated integer set with the same limit as integer-set and that contains all its values, and in addition each integer from low (inclusive) to high (exclusive) unless it is already equal to an existing member.

(integer-set-adjoin-range! integer-set low high)

A linear update procedure that returns an integer set with the same limit as integer-set and that contains all its values, and in addition each integer from low (inclusive) to high (exclusive) unless it is already equal to an existing member.

(integer-set-complement integer-set)

Returns a newly allocated integer set that is the complement of integer-set.

(integer-set-complement! integer-set)

A linear update procedure that returns a set that is the complement of integer-set.

(integer-set-min integer-set)

(integer-set-max integer-set)

Returns the smallest or largest integer in integer-set, or #f if there is none.

(integer-set-open-interval integer-set low high)

(integer-set-closed-interval integer-set low high)

(integer-set-open-closed-interval integer-set low high)

(integer-set-closed-open-interval integer-set low high)

Procedures that return a subset of integer-set contained in the interval from low to high. The interval may be open, closed, open below and closed above, or open above and closed below.

(integer-set-range= integer-set k)

(integer-set-range< integer-set k)

(integer-set-range<= integer-set k)

(integer-set-range> integer-set k)

(integer-set-range>= integer-set k)

Procedures that return an integer set containing the elements of integer-set that are equal to, less than, less than or equal to, greater than, or greater than or equal to k. Note that the result integer-set-range= contains at most one element.

(integer-set-delete-min! integer-set)

(integer-set-delete-max! integer-set)

Linear update procedures that return two values: the smallest or largest integer in integer-set or #f if there is none, and a set which contains all the elements of set except the integer being returned.