Modularize church primitive->factor function mapping code