NearestFunction
NearestFunction[data]
represents a function whose values give the elements closest to an element that is supplied.
Details
- NearestFunction works like Function.
- NearestFunction is generated by Nearest[data].
- NearestFunction[…][x] gives the element closest to a particular element x.
- NearestFunction[…][{x1,x2,…}] gives a list of the elements closest to each of the xi.
- NearestFunction[…][x,n] gives the n nearest elements.
- NearestFunction[…][x,{n,r}] gives the at most n nearest elements within radius r of x.
- NearestFunction[…][x,{All,r}] gives all elements within radius r of x.
Examples
open allclose allBasic Examples (1)
Generate a NearestFunction:
Apply to several elements using Map:
Scope (3)
Give the elements within radius 2:
Give the at most 3 nearest elements within radius 2:
When NearestFunction is directly applied to multiple points, results are computed in parallel threads if possible:
When the NearestFunction is applied to the points separately, results are computed serially:
Text
Wolfram Research (2007), NearestFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/NearestFunction.html.
CMS
Wolfram Language. 2007. "NearestFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/NearestFunction.html.
APA
Wolfram Language. (2007). NearestFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NearestFunction.html