Creating modular functions to be called by other custom functions.

Creating modular functions to be called by other custom functions.

How would you go about creating a function that is given an input and returns a value?

In my case I want to clean up phone numbers but I don't wish to rewrite the essential code 3 times over for each mobile, landline and alternative phone number. Ideally I create a separate function that processes a provided number which I can call from other custom functions.

The issue being that when I try to create a function to do so it must be associated with a module and is not allowed to return data.

An alternative solution would be to use a for each loop however this isn't really modular.

Is it possible within Zoho CRM to create functions independent of modules?