A continuous function from $\Bbb Q$ into $\Bbb Q$ which is never a rational function 
Let $f\colon\Bbb Q\longrightarrow\Bbb Q$ be a continuous function. Is there necessarily an interval $(a,b)$, with $a,b\in\Bbb Q$ such that $a<b$, such that the restriction of $f$ to $(a,b)\cap\Bbb Q$ is a rational function?

My guess is that the answer is negative. I tried to prove it as follows: I took a countable and dense set $\{r_n\mid n\in\Bbb N\}$ of irrational numbers and defined, for each $x\in\Bbb Q$, $f(x)=\sum_{r_n<x}2^{-n}$. This will work, in the sense that $f$ is continuous and that the restriction of $f$ to any interval $(a,b)$ is never a rational function. The problem is that, of course, in general, $f(x)\notin\Bbb Q$.
 A: Let's show the existence of a continuous function $f\colon \mathbb{R}\to \mathbb{R}$ such that $f(\mathbb{Q})\subset \mathbb{Q}$ and $f$ is a not a rational function on any interval.
For this, consider $A = \{a_1, a_2, \ldots, a_n\ldots\}$, $B= \{b_1, b_2, \ldots \}$  two countable dense subsets
of $\mathbb{R}$, labelled by $\mathbb{N}$.
Fact: there exists an increasing bijection $f\colon A\to B$. Indeed, consider the binary search tree corresponding to $A$ with its labelling, and to $B$ with its labelling. Because $A$, $B$ are both dense, the associated search tree will be complete binary trees. Now map the elements by considering the obvious bijection isomorphism between the two trees.
Note that $f$ extends (uniquely) to a homeomorphism of $\mathbb{R}$.
Now take $A= \mathbb{Q}$ with some labelling, and $B$ a subset of rationals such that the  denominators of its elements grow very fast ( faster than any polynomial).
To be explicit, take $B$ so that
$$| \{ b \in B \ | \operatorname{denom}(b)\le n \} |  = o(n^{\epsilon} )$$
for every $\epsilon> 0$.
Now, assume that  $f(\frac{m}{n}) = \frac{P(m,n)}{Q(m,n)}$ for all $\frac{m}{n} \in (\alpha, \beta)$, where $P$, $Q$ are homogenous of degree $d$ with integer coefficients. There exists for every $n$ at least $c n$ elements in $(\alpha, \beta)$ with numerator and denumerator $\le n$ ( a poor estimate, but enough for our purposes). Applying $f$ we conclude  $B$  contains at least $c n$ elements with denominator $\le k n^d$, for all $n$. We got a contradiction.
