Hi Thomas,
I have not taken much time to think about it, but I have to make a warning before hands. The function that is added to the primitive set is shared by every individual. Therefore, if it has some form of memory, every individual execution will affect its memory, and I doubt this is what you want.
If your function needs to remember a state, you should probably make the function a method of a new class and save the state in that class. You can then register in the pset the object's method. Just remember to reset the object state before each execution of a tree. If you want an example, take a look at the Artificial Ant example:
Regards,