TinyMARE HelpText

Global Functions > Nearest()

Nearest()

nearest(<list>,<target2>)
nearest(<list>,<target2>,<mode>)

This function returns the nearest number in a set of numbers--i.e. the element in <list> that is nearest to <target>.

<mode> can be one of L or G. If <mode> is l, the nearest number that <target> is less-than is returned, if <mode> is g, the nearest number that <target> is greater-than is returned. If <target> is not specified, the nearest match is chosen. If there are two matches equal distance from <target> the lesser number takes precedence. The closest match that can be made to a number is the number itself.

Examples:

Function Returns
[nearest(1 2 3 9,5)] 3
[nearest(1 2 3 9,5,L)] 9
[nearest(1 2 3 9,8,G)] 3
[nearest(1 2 3 4,4)] 4

See also: lnum(), randword()

Courtesy of WindsMerlin

-- SluggyQBFreak - 12 Jan 2006
Topic revision: r1 - 12 Jan 2006, SluggyQBFreak
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding WikiMARE? Send feedback