Write a Function That Can Return Unevaluated
The result of evaluating a Wolfram Language function may be the same as the input if the function is called with the wrong types of arguments. You can replicate that behavior in user-defined functions.
Using Argument Patterns...
If you invoke a function with arguments that do not match the argument patterns in its definition, it will return unevaluated.
Define f to take an integer argument:
f evaluates when it is called with an integer:
f returns unevaluated when it is called with a noninteger:
Using Conditional Tests...
If you add a condition to a function definition, the function will return unevaluated if the condition is not satisfied.
Define g to evaluate only if its argument is odd:
g evaluates when it is called with an odd integer:
g returns unevaluated when it is called with an even integer: