I think the function would have to manipulate global arrays (since arrays can not be passed as parameters) or use "variable variables" (dereference the a string as a name to get the array). Neither seems really desirable. I would be interested to see how you would decompose this for reuse.