Definition:
|
object x1 = smallest(sequence set,
bool return_index=false)
|
Description:
|
Returns the smallest element of set.
set: the sequence in which to find the smallest element.
return_index: if false (0), returns s[i], otherwise returns i.
The largest function is identical except that it returns the largest element.
|
pwa/p2js:
|
Supported.
|
Example:
|
?smallest({"this",{3,5,7},9}) -- prints 9
?largest({"this",{3,5,7},9}) -- prints "this"
|
Implementation:
|
See builtins\psmall.e (an autoinclude) for details of the actual implementation.
|
See Also:
|
min
|
Technicalia
|
This differs from the Euphoria version of smallest() in std\stats.e in (at least) three ways:
* The set passed in the first parameter must be a non-empty sequence (compilation or run-time error if passed an atom or {})
* It can return non-atoms in the set (if no atoms occur, it will be the first in an alphabetical and case-sensitive ordering)
* It can return the index of the lowest entry, rather than the actual value of the lowest entry.
This should not, imho, cause sensibly-written code to be incompatible/misbehave. Despite the fact this is an autoinclude,
consider explicitly including this with a namespace and using that to qualify any calls, to avoid potential problems with
code written and tested on Phix, should you later try and run it on Euphoria.
This routine is very similar to min(), except that this has the optional return_index parameter, and
that routine also has other incompatibilities with Euphoria (non-recursive processing etc).
|