Functions preserving classes of languages