1\DOC intersect
2
3\TYPE {intersect : ''a list -> ''a list -> ''a list}
4
5\SYNOPSIS
6Computes the intersection of two `sets'.
7
8\KEYWORDS
9list, set, eqtype.
10
11\DESCRIBE
12{intersect l1 l2} returns a list consisting of those elements of {l1} that
13also appear in {l2}.
14
15\FAILURE
16Never fails.
17
18\EXAMPLE
19{
20- intersect [1,2,3] [3,5,4,1];
21> val it = [1, 3] : int list
22}
23
24
25\COMMENTS
26Do not make the assumption that the order of items in the list
27returned by {intersect} is fixed. Later implementations may use
28different algorithms, and return a different concrete result
29while still meeting the specification.
30
31A high-performance implementation of finite sets may be found in
32structure {HOLset}.
33
34ML equality types are used in the implementation of {intersect}
35and its kin. This limits its applicability to types that
36allow equality. For other types, typically abstract ones,
37use the `op_' variants.
38
39\SEEALSO
40Lib.op_intersect, Lib.union, Lib.U, Lib.mk_set, Lib.mem, Lib.insert, Lib.set_eq, Lib.set_diff.
41\ENDDOC
42