# Sufficient conditions for bounded function?

Consider a function $f:[a,b]\subset\mathbb{R}\rightarrow\mathbb{R}$. Does the fact that the domain of $f$ is a compact set of the real line imply that $f$ is bounded on $[a,b]$? In the negative case, could you give a counterexample of a function $f:[a,b]\subset\mathbb{R}\rightarrow\mathbb{R}$ that is not bounded?

-

If $f$ is continuous, $f$ is bounded (extreme value theorem).
Else, not necessarily : take $f:[0,1] \to \mathbb R$ defined by $f(0) = 1$ and $f(x) = \frac1x$ if $x\not= 0$. Then $f$ is not bounded.
$$f(x)=\begin{cases}\frac1x; & x>0\\ 0; & x=0\end{cases}$$ is not bounded on $[0,1]$.