max#

Return the numerically largest value in the list.

תקציר#

my $hi = max @values;
my $hi = max 3, 9, 12;           # 12

מה מוחזר#

A single number. If every argument is an integer the result is returned as an integer; otherwise it is returned as a float. An empty list yields undef.

דוגמאות#

my $n = max 1..10;               # 10
my $n = max @bar, @baz;          # largest across concatenated lists
my $n = max();                   # undef

מקרי קצה#

  • Empty list returns undef.

  • Strings are compared numerically (use maxstr for lexical order).

הבדלים מן ה-upstream#

Fully compatible with upstream.

ראו גם#

  • min - the numerical minimum counterpart.

  • maxstr - string-wise maximum (gt semantics).

  • reduce - custom maxima (e.g. by a key function).