1\DOC assoc
2
3\TYPE {assoc : ''a -> (''a * 'b) list -> 'b}
4
5\SYNOPSIS
6Searches a list of pairs for a pair whose first component equals a
7specified value, then returns the second component of the pair.
8
9\KEYWORDS
10list.
11
12\DESCRIBE
13{assoc x [(x1,y1),...,(xn,yn)]} locates the first {(xi,yi)} in a left-to-right
14scan of the list such that {xi} equals {x}. Then {yi} is returned. The lookup
15is done on an eqtype, i.e., the SML implementation must be able to decide equality
16for the type of {x}.
17
18\FAILURE
19Fails if no matching pair is found. This will always be the case if
20the list is empty.
21
22\EXAMPLE
23{
24- assoc 2 [(1,4),(3,2),(2,5),(2,6)];
25> val it = 5 : int
26}
27
28
29\SEEALSO
30Lib.assoc1, Lib.assoc2, Lib.rev_assoc, Lib.mem, Lib.tryfind, Lib.exists,
31Lib.all.
32
33\ENDDOC
34