It would be more idiomatic to make the function behavior conditional on something that you can change — can be a parameter, a shared variable (if you are using threads), or something you read from a file. The implementation of how you propose to do
is crucial. Also, perhaps you could give more context: what is it you are trying to do?