On this page:
list->set
list->seteq
list->seteqv
set=?
proper-subset?
set->list
set-exclusive-or
Version: 5.0.2

21 Sets

Carl Eastlund <cce@racket-lang.org>

 (require unstable/set)

This library is unstable; compatibility will not be maintained. See Unstable for more information.

This module provides tools for representing finite sets.

(list->set lst)  set?
  lst : list?
(list->seteq lst)  set?
  lst : list?
(list->seteqv lst)  set?
  lst : list?
Produces the appropriate type of set containing the elements of the given list.

Examples:

  (define lst
    (list 'atom (expt 2 100) (list 'compound)
          'atom (expt 2 100) (list 'compound)))
  > (list->set lst)

  #<set: atom (compound) 1267650600228229401496703205376>

  > (list->seteqv lst)

  #<set: atom (compound) (compound) 1267650600228229401496703205376>

  > (list->seteq lst)

  #<set: atom (compound) (compound) 1267650600228229401496703205376 1267650600228229401496703205376>

(set=? a b)  boolean?
  a : set?
  b : set?
Reports whether two sets contain the same elements.

Examples:

  > (set=? (set 1) (set 1 2 3))

  #f

  > (set=? (set 1 2 3) (set 1))

  #f

  > (set=? (set 1 2 3) (set 1 2 3))

  #t

(proper-subset? a b)  boolean?
  a : set?
  b : set?
Reports whether b contains all of the elements of a, and at least one element not in a.

Examples:

  > (proper-subset? (set 1) (set 1 2 3))

  #t

  > (proper-subset? (set 1 2 3) (set 1))

  #f

  > (proper-subset? (set 1 2 3) (set 1 2 3))

  #f

(set->list s)  list?
  s : set?
Produces a list containing the elements of s.

Example:

  > (set->list (set 1 2 3))

  '(1 2 3)

(set-exclusive-or s ...+)  set?
  s : set?
Produces a set containing only those elements found in each s an odd number of times.

Example:

  > (set-exclusive-or (set 1) (set 1 2) (set 1 2 3))

  #<set: 1 3>