Use std::transform in pre homomorphism