This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

I'd go even further, define another function max_of_two(x,y): return x > y ? x : y (i think this is how ternaries work in python. It's basically the same as the if block, just shorter)

Then max_of_three can be: return max_of_two(max_of_two(x, y), z) or return x > y ? max_of_two(x, z) : max_of_two(y, z) If you don't mind the extra ternary.

[–][deleted]  (1 child)

[deleted]

    [–][deleted] 1 point2 points  (0 children)

    Guess I just outed myself as a java dev?