Define your own custom functions that take as many arguments as you wish.
Add a condition to your function so that the function is only called if the specified condition is true.
You can even define recursive function that calls itself. You normally need to define at least two such function with same name, one for base case and one for default case.