Implementation of arrfunc_factory