You don't. You write two copies of the algorithm.