I couldn't come up with a vectorized way to do this but I agree that it seems like there should be.