## Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

## Compact integer sets

The `cis` library implements compact integer sets, represented as a list of integer intervals. The usual set operations are provided. The advantage compared to ordered lists is that when many elements are contiguous, the actual size of the data structure may be much smaller than the cardinality of the set being represented. Most set operations are linear w.r.t. the size, not the cardinality of the set.

## TOC »

## Usage

(require-extension cis)

## Documentation

### Constants

empty :: CIS

The empty integer set.

### Procedures

`cis?`procedureReturns

`#t`if the given object is a compact integer set,`#f`otherwise.

`empty?`procedureReturns

`#t`if the given integer set is empty,`#f`otherwise.

`subset?`procedureReturns

`#t`if the first given integer set is a subset of the second given integer set,`#f`otherwise.

`cardinal`procedureReturns the cardinality of the given set.

`in?`procedureReturns

`#t`if the the given integer is contained in the given set,`#f`otherwise.

`singleton`procedureReturns an integer set consisting of the given element.

`interval`procedureReturns an integer set consisting of the given interval of elements.

`add`procedureAdds the given element to the given set and returns the new set.

`remove`procedureRemoves the given element from the given set and returns the new set.

`shift`procedureAdds the given integer to all elements in the set and returns the new set.

`union`procedureReturns the union of the two sets.

`intersection`procedureReturns the intersection fo the two sets.

`difference`procedureSubtracts the elements of the second given set from the elements of the first given set, and returns the resulting set.

`get-min`procedureReturns the minumum element of the set.

`get-max`procedureReturns the maximum element of the set.

`foreach`procedureApplies the given procedure to every element of the set.

`fold-left`procedureLeft fold on the elements of the set.

`fold-right`procedureRight fold on the elements of the set.

`elements`procedureReturns a list containing all elements of the given set.

## Examples

(define a (add 4 (add 1 (add 5 empty)))) (define b (add 3 (add 2 (add 8 empty)))) (elements a) ==> (5 4 1) (elements b) ==> (8 3 2) (elements (union a b)) ==> (8 5 4 3 2 1)

## About this egg

### Author

`cis` is based on the Ocaml `Cis` library by SÃ©bastien FerrÃ©. The Chicken Scheme variant of `cis` is implemented by Ivan Raikov.

### Version history

- 1.2
- Bug fix in union
- 1.1
- Updated test script to return proper exit code
- 1.0
- Initial release

### License

Copyright 2010-2012 Ivan Raikov and the Okinawa Institute of Science and Technology This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. A full copy of the GPL license can be found at <http://www.gnu.org/licenses/>.