▼ |  | Unstable

1 | Guidelines for developing unstable libraries
2 | Bytes
3 | Classes and Objects
4 | Contracts
5 | Definitions
6 | Dictionaries
7 | Directories
8 | Exceptions
9 | Filesystem
10 | Functions
11 | Lists
12 | Net
13 | Path
14 | PLane T Packages
15 | Ports
16 | Pretty-Printing
17 | Regular Expressions
18 | Requiring Modules
19 | Sandboxed Evaluation
20 | Scribble Documentation
21 | Sets
22 | S-Expression Diff
23 | Source Locations
24 | Strings
25 | Structs
26 | Syntax
27 | Planet Package Macros
28 | Text Representations
29 | Multiple Values
30 | XML and CSS
31 | Polymorphic Contracts
32 | Finding Mutated Variables
33 | Find
34 | Interface-Oriented Programming for Classes
35 | Sequences
36 | Hash Tables
37 | Match
38 | Generics
39 | Mark Parameters
40 | Debugging
41 | Contracts for macro subexpressions
42 | Contracts for struct type properties
43 | GUI libraries

On this page:

list->set
list->seteq
list->seteqv
set=?
proper-subset?
set->list
set-exclusive-or

Version: 5.0.2
top ← prev up next →

### 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>

top ← prev up next →