max
Definition: |
object x1 = max(object x2, x3)
-- or -- object x1 = sq_max(object x2, x3) -- or -- object x1 = max(sequence s1) -- or -- object x1 = maxsq(sequence s1, bool return_index=false) |
Description: |
Returns the largest of x2 and x3, or the largest element in sequence s1.
Atoms are considered to be less than sequences. Sequences are compared "alphabetically" (case sensitive,
ie 'a'>'Z') starting with the first element until a difference is found.
The sq_max(a,b) function applies max() to the top-level elements of a and b when they are in fact sequences, otherwise it applies an atom to all the elements of the other, or if they are both atoms it behaves identically to max(a,b). Typically the result is a sequence, but it can be an atom if passed two atoms. Note that it is not recursive, and passing a single argument to sq_max() is not allowed. |
pwa/p2js: | Supported. |
Example: |
a = max(7,5) -- a is 7 b = max({7,5,3}) -- b is 7 c = max("two","three") -- c is "two" d = max({"one","two","three","four"}) -- d is "two" s = sq_max(s,0) -- no element of s is now < 0 |
Implementation: | See builtins\pmaths.e (an autoinclude), and psqop.e, and the technicalia dropdown, for details of the actual implementation. |
See Also: | largest, equal, compare, min, relational operators, sequence operations |