Next: , Previous: , Up: Top   [Contents][Index]


11 Purely functional sets

For all the procedures: the argument ITEM< must be the ordering procedure: a predicate function accepting two arguments and returning a boolean, #t if the first argument is strictly less than the second. For numeric collected items: ITEM< can be <; for string collected items: ITEM< can be string<?.

The following bindings are exported by the library (pfds sets).

Function: make-set ITEM<

Return a new empty set ordered by the procedure ITEM<.

Function: set? OBJ

Return #t if OBJ is a set, #f otherwise.

Function: set-member? set item

Return #t if item is in set, #f otherwise.

Function: set-insert set item

Return a new set created by inserting item into set.

Function: set-remove set item

Return a new set created by removing item from set.

Function: set-size set

Return an exact integer representing the number of items in set.

Function: set<? set1 set2
Function: proper-subset? set1 set2

Return #t if set1 is a proper subset of set2, #f otherwise. That is, if all items of set1 are in set2, and there is at least one item of set2 not in set1.

Function: set<=? set1 set2
Function: subset? set1 set2

Return #t if set1 is a subset of set2, #f otherwise, i.e. if all items of set1 are in set2.

Function: set=? set1 set2

Return #t if every item of set1 is in set2, and vice versa, #f otherwise.

Function: set>=? set1 set2

Return #t if set2 is a subset of set1, #f otherwise.

Function: set>? set1 set2

Return #t if set2 is a proper subset of set1, #f otherwise.

Function: set-map mapper set

Return the new set created by applying the procedure mapper to each item of set.

Function: set-fold COMBINE ACCUM-BASE set

Return the value obtained by iterating the procedure COMBINE over each item of set and an accumulator value (in this order). The value of the accumulator is initially ACCUM-BASE, and the return value of COMBINE is used as the accumulator for the next iteration.

Function: list->set list-of-items ITEM<

Return the set containing all the items of the given list, ordered by ITEM<.

Function: set->list set

Return all the items of set as a list.

Function: set-union set1 set2

Return the union of set1 and set2, i.e. a new set that contains all items of set1 and set2.

Function: set-intersection set1 set2

Return the intersection of set1 and set22, i.e. a new set of all items that are in both set1 and set2.

Function: set-difference set1 set2

Return the difference of set1 and set2, i.e. the set of all items in set1 that are not in set2.

Function: set-ordering-procedure set

Return the ordering procedure used internally by set.


Next: , Previous: , Up: Top   [Contents][Index]

This document describes version 0.5.0-devel.1 of MMCK PFDS.