The max() is not enough

R, 50 37 bytes

-33 bytes thanks to digEmAll! -13 bytes thanks to rturnbull!

x=scan(se=",");if(any(diff(x)))max(x)

Try it online!


Perl 6, 26 23 22 bytes

-1 byte thanks to nwellnhof

{.max if .Set>1}o&EVAL

Try it online!

Returns an empty slip if everything is equal.

Explanation

                o&EVAL  # Eval the string to a list of integers
{              }         # Pass to code block
 .max            # Return the max
      if .Set>1  # If the list converted to a set has more than one element

MathGolf, 5 bytes

è▀s╞╙

Try it online!

Explanation

è      Read whole input as int array
 ▀     Get unique elements
  s    Sort list
   ╞   Discard from left of array
    ╙  Get maximum of list

This works because both the max operator and the discard from left operator don't do anything for empty lists. Well, the max operator removes the list and pushes nothing for empty lists.

It could be 4 bytes if input could be taken as a list.

Tags:

Code Golf