Next: Enumerated/finite types and sets, Up: Libraries
Scheme48 provides a facility for generalized boxed bitwise-integer
masks. Masks represent sets of elements. An element is any arbitrary
object that represents an index into a bit mask; mask types are
parameterized by an isomorphism between elements and their integer
indices. Usual abstract set operations are available on masks. The
mask facility is divided into two parts: the mask-types
structure, which provides the operations on the generalized mask type
descriptors; and the masks structure, for the operations on
masks themselves.
Make-mask-typeconstructs a mask type with the given name. Elements of this mask type must satisfy the predicate elt?. Integer->elt is a unary procedure that maps bit mask indices to possible set elements; elt->integer maps possible set elements to bit mask indices. Size is the number of possible elements of masks of the new type, i.e. the number of bits needed to represent the internal bit mask.Mask?is the disjoint type predicate for mask objects.
Mask-typereturns mask's type.Mask-has-type?returns#tif mask's type is the mask type type or#fif not.
The mask-types structure, not the masks structure,
exports mask? and mask-has-type?: it is expected that
programmers who implement mask types will define type predicates for
masks of their type based on mask? and mask-has-type?,
along with constructors &c. for their masks.
Integer->maskreturns a mask of type type that contains all the possible elements e of the type type such that the bit at e's index is set.List->maskreturns a mask whose type is type containing all of the elements in the list elts.
Mask->integerreturns the integer bit set that mask uses to represent the element set.Mask->listreturns a list of all the elements that mask contains.
Mask-member?returns true if elt is a member of the mask mask, or#fif not.Mask-setreturns a mask with all the elements in mask as well as each elt ....Mask-clearreturns a mask with all the elements in mask but with none of elt ....
Set operations on masks.
Mask-unionreturns a mask containing every element that is a member of any one of its arguments.Mask-intersectionreturns a mask containing every element that is a member of every one of its arguments.Mask-subtractreturns a mask of every element that is in maska but not also in maskb.Mask-negatereturns a mask whose members are every possible element of mask's type that is not in mask.