use code_mapmean to generate map-mean functions