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]$)
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'}$.