This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.

# Nearest

 Nearest[{elem1, elem2, ...}, x]gives the list of elemi to which x is nearest. Nearest[{elem1->v1, elem2->v2, ...}, x]gives the vi corresponding to the elemi to which x is nearest. Nearest[{elem1, elem2, ...}->{v1, v2, ...}, x]gives the same result. Nearest[{elem1, elem2, ...}->Automatic, x]takes the vi to be successive integers i. Nearest[data, x, n]gives the n nearest elemi to x. Nearest[data]generates a NearestFunction[...] which can be applied repeatedly to different x.
• If the elemi are vectors or matrices of numbers, Nearest by default in effect uses the metric Norm[#1-#2]&.
• For strings, Nearest by default uses the edit distance metric.
• The following option can be given:
 DistanceFunction Automatic the distance metric to use
• When several elements are returned, the nearest ones are given first.
• If several elements are at the same distance, they are returned in the order they appear in data.
Find the element nearest to 20:
 Out[1]=
Find the 3 elements nearest to 20:
 Out[2]=

Find which element is nearest to {2, 3} in 2D:
 Out[1]=

Find "nearest" strings:
 Out[1]=
 Applications   (6)
New in 6