# Existence of an “open to closed” and “closed to open” function

Somebody knows if there exists a function $f:\mathbb{R}\to\mathbb{R}$, with it's usual topology, such that the image (or preimage) of every open set is closed and the image (or preimage) of every closed set is open? If not, is possible find such a function between some topological spaces (without consider the discrete topology off course)?

Thank you.

For inverse image, constant maps have this property because the preimage of anything is either the empty set or all of $\mathbb R$, and both are closed and open at the same time.
The only interesting question is, are constant functions the ONLY ones with this property (for pre-image)? The answer is yes; the pre-image of every point must be open, and $\mathbb R$ is connected, so it can't be the union of disjoint open sets.