"Piecewise Continuity" of $f$ Suppose $M$ is a metric space and $\{ A_i \}$ is a countable collection of closed subsets of $M$ whose union is $M$ and s.t. $f$ restricted to $A_i$ is continuous for each $i$. Give an example to show that $f$ need not be continuous on all of $M$. 
My instinct has been to construct some relatively simple function on $\mathbb{Q}$, but I'm wondering now if the example might be more pathological. 
 A: Take $M = \{ 0 \} \cup \{\frac{1}{n}\}_{n=1}^{\infty}$, with the usual metric on $\mathbb{R}$. Define $f : M \rightarrow \mathbb{R}$ by $f(\frac{1}{n}) = 1$, $f(0) = 0$.
Then let $A_0 = \{0\}$, $A_n = \{\frac{1}{n} \}$, for $n=1,...$. $f$ restricted to each $A_i$ is trivially continuous, but $f$ is not continuous at $0$ (and $M$ is the union of the $A_i$).
A: Let $X$ be any countably infinite space whose topology is $T_1$ but not discrete, and let $f:X\to\Bbb N$ be a bijection. Give $\Bbb N$ the discrete topology. Then $X$ is the union of the countably many closed sets $\{x\}$ such that $x\in X$, and of course $f\upharpoonright\{x\}$ is continuous for each $x\in X$, but $f$ is not continuous on $X$. If $X=\Bbb Q$ with the usual topology, $f$ is not continuous at any point of $X$.
If you want the space $X$ to be compact, you can take it to be $[0,1]$ and use the function 
$$f:[0,1]\to[0,1]:x\mapsto\begin{cases}
0,&\text{if }x=0\\
1,&\text{if }0&ltx\le 1\;.
\end{cases}$$
Take your closed sets to be $F_0=\{1\}$ and the intervals $F_n=\left[\frac1n,1\right]$ for $n\in\Bbb Z^+$; $f$ is constant and therefore certainly continuous on each of the closed sets $F_n$.
