Is there a "nice" example of a function $f$ such that $f(x)$ is non-periodic but the composition $f(f(x))$ is? By nice I mean that preferably it will be defined entirely on the domain $R$ and be continuous/differentiable with the composition having non-zero period.
For example the function $f(x>0)=-x, f(x \leq 0) = 0$ is not nice.
A very simple example: $f(x)=\sin|x|$.