Uniformly continuous only on compact space Heine–Cantor theorem state that if $M$ is compact then the continuous function $f:M\to N$ is uniformly continuous.
Is there a continuous function $f:A\to\Bbb R^n$ such that $f$ is uniformly continuous on $B\subset A$ implies $B$ is compact, i.e. $f$ is uniformly continuous only on compact space?
I thought about using some function $f:\Bbb R\to \Bbb R$, like $x\mapsto x^2$ but I don't know how to approach to this if $B$ is between 2 finites numbers (like $B=(0,1]$)
 A: If $f :\mathbb  R \to \mathbb R$ is uniformly continuous on compact sets, you can say that $f$ is uniformly continuous on $[0, 1]$, which means that for all $\epsilon > 0$ there exists $\eta >0$ such that for all $x, y \in [0,1]$ such that $|x-y| \leq \eta$, $|f(x)-f(y)| \leq \epsilon$.
Which means that $f$ is uniformly continuous on $(0,1)$ which is open and therefore not compact.
A: This is only possible, if all subsets of $A$ are compact, but then the statement is trivial. (Such sets $A$ do exists, take for example a finite set $A$.)
Let $A \subset \mathbb R^m$, $f: A \to \mathbb R^n$ continuous and $B \subset A$ not compact. For some $R \gt 0$ the set $$B' := B_R(0) \cap B$$ is not empty. $B'$ is not compact (else $B$ would be compact).
However, $\overline{ B'}$ is compact, hence for all $\varepsilon \gt 0$ there exists $\delta \gt 0$ such that $\|f(x) - f(y)\| \lt \varepsilon $ for $\|x - y\| \lt \delta$ and $x, y \in \overline{B'}$. This is obviously also true for $x, y \in B'$, as $B' \subset \overline{B'}$.
