# A question about “nice” functions

Let $f:\mathbb R \rightarrow \mathbb R$ be a function such that $\lambda(I)=\lambda(f(I))$ for each interval $I \subseteq \mathbb R$. ($\lambda$ is Lebesgue measure here.) Let us call such functions ''nice'' functions.

Can we characterize nice functions?

For example;

$f(x)=x$ is a nice function.

$f(x)=2x$ is not a nice function. More generally if $m \in \mathbb R\setminus\{-1,1\}$ then $f(x)=mx$ is not a nice function.

Every translation is a nice function.

$$f(x)= \begin{cases} x+1; & x \in [-1,0) \newline x-1; & x \in [0,1) \newline x; & \text{elsewhere} \end{cases}$$ is a nice function.

Further, let $\mathcal A$ be the family of nice functions. Is the following conclusion true?

$f \in \mathcal A$ iff there exists a partition $I_{\alpha}$ of $\mathbb R$ into pairwise disjoint intervals such that $f=ax+b_{\alpha}$ on $I_{\alpha}$ for $a=-1$ or $1$ and for suitable $b_{\alpha}$.

Let $C \subset \mathbb{R}$ be a fat Cantor set that is symmetric w.r.t. $0$ and define $f(x) = \begin{cases}x,& \text{if }x \in C\\\ -x,& \text{if }x \notin C \end{cases}.$
(More trivial counterexample would be $f(x) = \begin{cases}x,& \text{if }x \notin \mathbb{Q}\\\ 0,& \text{if }x \in \mathbb{Q} \end{cases}$, but changing things in a set of measure zero is not that satisfying.)
Edit: Perhaps even more satisfying example would be something like $f(\sum_{i=0}^\infty x_i2^{-i}) = \sum_{k=0}^\infty (1-x_{2k})2^{-2k}+\sum_{k=0}^\infty x_{2k+1}2^{-2k-1}$ with $x_i \in \{0,1\}$, i.e. switch every other digit in the binary representation (does not matter what you do at the endpoints of intervals).