Max of the reversed of two numbers
Wren, 126 124 bytes
As always Wren is the longest. I hate Wren's verbosity.
Fn.new{|a|a.map{|i|i>0?"":"-"+(i.abs.toString[-1..-(i.abs.toString.count)])}.map{|i|Num.fromString(i)}.reduce{|x,y|x<y?x:y}}
Try it online!
Explanation
Fn.new{ // new anonymous function
|a| // with the parameter a
a.map{|i| // for each item in this parameter
(i>0)?"":"-" // The sign of each item. If the item is larger than 0, return the null string, otherwise return a negative sign.
+( ) // Append this with the following string:
i.abs // The absolute value of i
.toString // Convert this value to a string
[-1..-(i.abs.toString.count)] // Reverse this string
Num.fromString( ) // convert this to a number from a string
}.reduce{|x,y|x<y?x:y}} // Find the minimum value of the list
Perl 5, 51 bytes:
sub f{($x,$y)=map{/-?/;$&.reverse$'}@_;$x>$y?$x:$y}
Try it online!
...or if using a function from a core module is allowed (max
in List::Util
) it's 35 bytes:
35 bytes:
sub f{max map{/-?/;$&.reverse$'}@_}
Try it online!
Zsh, 63 bytes
for x;a+=(${(M)x#-}${(j::)${(Oas::)x#-}})
<<<$a[1+$[a[1]<a[2]]]
Try it online!
${x#-}
removes the leading -
if it exists. Adding the (M)
flag causes the -
to be substituted instead of what remains.
Then this construct reverses the remaining string: ${(j::)${(Oas::)var}}
.
For each element, we append to an array, then use a comparison to index into the array.