Where's the Julia programmer that hits every one of these with @benchmark and then works for six hours to shave three nanoseconds off of the fastest one?
GNU C. Also works with Clang. Avoids evaluating the arguments multiple times. The optimizer will convert the branch into a conditional move, if it doesn't I'd replace the ternary with the "bit hacker 2" version.
Engineer I guess... Thief is the objectively better enterprise programmer option but I don't know why I always forget about it and just write a ternary ¯\_(ツ)_/¯
And then your customer changes their mind. Instead of two numbers, they will now input three numbers. How easy will it be for you to change your code?
And then the customer changes their mind. Instead of three numbers, they will now input any series of numbers. How easy will it be for you to change your code? And why didn't you already do this is the previous step?
And then the customer changes their mind. Instead of any set of numbers, they will now input numbers and text. How easy will it be to change your code?
And then the customer changes their mind. They now have no idea of what they're sending you or if they're even sending you anything.
Nevermind the code now, you already did that in the previous step, right?
How easy will it be to explain what you're invoicing them for?
Otherwise, realistically, I’m prob the worst of all worlds … the procrastinator waiting/hoping to be the pair programmer that has hopefully remembered to just be the thief.
here’s another mathematical approach (that has the added benefit of only working when x and y are both positive).
let f denote the linear functional on ℝ2 defined by f(1,0) = x and f(0,1) = y (and extend by linearity). then the operator norm || f || is equal to max(x,y).