For $x \in \mathbb{R}$, define $r(x)$ as follows: $$ r(x)= \begin{cases} 1 &\text{if $x$ is rational},\\ 0 &\text{if $x$ is irrational}. \end{cases} $$
Q. What is $\int_0^1 r(x) dx$ ?
I know the rationals are dense in an interval, but countable, and so "sparse."
My motivation is a desire to average over the rationals, and in some sense this integral would be the denominator. If the integral is zero, then I'll have to think of another route. Thanks!