There actually is a command for that: `a, b = extrema(r)`