TITLE: If every real valued continuous function on $X$ is uniformly continuous , then is every continuous function to any metric space uniformly continuous?
QUESTION [9 upvotes]: Let $X$ be a metric space such that every continuous function $f:X \to \mathbb R$ is uniformly continuous ( here $\mathbb R$ is equipped with the standard euclidean metric ) , then is it true that for any metric space  $Y$ , every continuous function $f:X \to Y$ is uniformly continuous ?

REPLY [4 votes]: Suppose $f:X\to Y$ is continuous but not uniformly continuous. Then there exists $\epsilon>0$ and sequences $x_n,y_n$ in $X$ such that $d_X(x_n,y_n)\to 0$ and $d_Y(f(x_n),f(y_n))\ge \epsilon$ for all $n.$ Note that no subsequence $x_{n_k}$ can converge in $X$: If $x_{n_k} \to x,$ then $y_{n_k} \to x$ as well, hence $d_Y(f( x_{n_k}),f(y_{n_k})) \to 0$ by the continuity of $f$ at $x,$ contradicition. Similarly, no subsequence $y_{n_k}$ can converge in $X.$
Now there is a subsequence $n_k$ such that $x_{n_1},y_{n_1},x_{n_2},y_{n_2}, \dots$ are all distinct. To see this, take $n_1 = 1.$ Because $x_1,y_1$ are distinct, we're off to a good start. By the remarks above, we know $x_n\in \{x_1,y_1\}$ for only finitely many $n.$ Same for $y_n.$ Hence it's clear there is $n_2$ such that $x_{1},y_{1},x_{n_2},y_{n_2}$ are all distinct. This process can be continued, giving the desired $n_k$'s.
Let $E= \{x_{1},y_{1},x_{n_2},y_{n_2},\dots\}.$ Then $E$ has no limit points in $X.$ Otherwise we would have a subsequence of $x_n$ or $y_n$ converging to a point of $X,$ contradiction. It follows that $E $ is closed in $X.$ In its relative topology, $E$ is discrete. Thus any function $g:E \to \mathbb {R}$ whatsoever is continuous on $E.$ Let's take $g = 0$ on $\{x_{n_k}\},$ $g = 1$ on $\{y_{n_k}\}.$ By the Tietze extension theorem, $g$ extends to a function $G:X\to \mathbb {R}$ that is continuous on $X.$ Clearly the behavior of $g$ on $E$ shows $G$ is not uniformly continuous on $X.$ This is a contradiction, and proves the result.