Doing a function or procedure in a rules file

Which language? If Rules DSL, see Reusable Functions: A simple lambda example with copious notes but be sure to pay attention to the limitations (only visible in that one .rules file, everything needed myst be passed in as an argument, limit of seven arguments total.

But, if you want to do this, it’s probably a sign that you’ve outgrown Rules DSL and would be happier with any of the other rules language options where you’ll have full language features.