How to solve Problem 18, Chapter 5, Spivak Calculus? I have been working on Spivak's calculus book. I am currently on chapter 5: limits.
The problem: proof that if $ f(x)=x$ for $x$ rational and $f(x)=-x$ for $x$ irrational, then $\lim_{x \to a }f(x)$ does not exist if $a\neq0$. 
My solution: 
I split the limit into to sequences $\lim_{x\to a} f(x)= l_1$ where $x\in \mathbb{R} \setminus \mathbb{Q}$ and then $\lim_{x\to a} f(x)= l_2$ where $x\in \mathbb{R} \setminus \mathbb{Q}$, so if $\lim_{x \to a} f(x)= L$ exists, then $l_1=l_2=L$. The limit should be the same regardless of how I approach a. 
Now: 


*

*For $x\in \mathbb{Q}$, I have that if $0<|x-a|<\delta$, then if $\epsilon= \delta$, $|f(x)-a|<\epsilon$, so $l_1=a$

*For $x\in \mathbb{R} \setminus \mathbb{Q}$, I have that if $0<|x-a|<\delta$, then if $\epsilon= \delta$, $|x-a|=|-(x-a)|=|f(x)+a|<\epsilon$, so $l_2=-a$.


For 
 $\lim_{x\to a} f(x)$ to exist then $l_1=l_2=L$ and that only happens for $a=0$. 
Is this reasoning right? 
 A: I disagree with your exposition, because you have implicitly used the fact that the rationals are dense in the reals, and similarly, the irrationals are dense in the reals.  That is to say, for every pair of $a, b \in \mathbb R$ with $a < b$, there exists a rational number $p/q \in \mathbb Q$ such that $a < p/q < b$.  Furthermore, there also exists an irrational number $c \in \mathbb R \setminus \mathbb Q$ such that $a < c < b$.  You need these properties to state that, for any $\epsilon > 0$, there exists a neighborhood $\delta$ around $a$ such that whenever $0 < |x - a| < \delta$, $|f(x) - L| < \epsilon$.
To make it clear, suppose that instead of $\mathbb Q$, we dealt with $\mathbb Z$.  In other words, suppose $$g(x) = \begin{cases} x, & x \in \mathbb Z \\ -x, & x \in \mathbb R \setminus \mathbb Z. \end{cases}$$  Does this function have a limit at, say, $x = 1/2$?  The answer is yes.  Does this function have a limit at, say, $x = 1$?  Again, the answer is yes.  Why is this function qualitatively different than the original function $f$ in your question?  If I applied your argument to $g$, where does it break down?
