Is the space of squared integrable functions on a compact set separable? Let $X$ be a compact subset of $\mathbb R^p$, is the space of square integrable functions on $X$, $L_2(X)$, separable ? 
This is true indeed for closed intervals with $p=1$ since we can use Fourier analysis to construct a countable base. This is as well true for  $p > 1$ if we take products of closed intervals $X=[a_1, b_1]\times...\times [a_p, b_p]$ for the same reason. However is it true for any compact space $X$ or do we additional conditions on $X$ ? 
 A: Claim: if $X$ is a compact metric space and $\mu$ is a finite measure on $\mathcal{B}(X)$, the Borel sets of $X$, then $L^p(X, \mathcal{B}(X), \mu)$ is separable for each $1\leq p<\infty$. 
We can prove it as follows: For each $n\in \mathbb{N}$, consider a finite collection of balls of radii $1/n$ that cover $X$, and let $\mathcal{P}_n$ be the partition they generate.  Then let $\mathcal{A}\subset L_p(X, \mathcal{B}(X), \mu)$ be the countable collection of all rational linear combinations of, characteristic functions of sets in $\bigcup\limits_n \mathcal{P}_n$, and the function that is identically $1$. We start by showing that for open $U\subset X$, $\mathcal{X}_U$ can be approximated by functions in $\mathcal{A}$. For each $n\in \mathbb{N}$, define $U_n:=\bigcup\limits_{B(x;1/n)\subset U}\{x\}$. Then we see that $\{U_n\}_n$ is an increasing sequence of closed subsets contained in $U$ whose union is in fact $U$. Hence $\lim_{n\rightarrow \infty} \mu(U_n)=\mu(U)$ and in particular we can, for fixed $\epsilon>0$, find a $k\in\mathbb{N}$ s.t. $\mu(U_k)>\mu(U)-\epsilon^p$. Consider then the function $f:=\sum\limits_{P\in \mathcal{P}_k :P\cap U_k \neq\emptyset}\mathcal{X}_P\in \mathcal{A}$. We see that $\lVert f-\mathcal{X}_U \rVert_p\leq \mu(U\backslash U_k)^{1/p}<\epsilon$. We then see that the set $\mathcal{C}:=\{B\in \mathcal{B}(X): \mathcal{X}_B \text{ can be approximated by functions in }\mathcal{A}\}$ contains the open sets and we can show that it is a sigma-algebra; that it is closed under unions is straightforward to prove and it is also closed under complements: if $B\in\mathcal{C}$ and $\epsilon>0$ is given, let $f\in \mathcal{A}$ be s.t. $\lVert f-\mathcal{X}_B\rVert_p<\epsilon$. Then $1-f\in \mathcal{A}$ and we see that $\lVert (1-f)- \mathcal{X}_{X\backslash B}\rVert<\epsilon \rightarrow X\backslash B\in \mathcal{C}$. We conclude that for any Borel set $B$, the characteristic function of $B$ can be approximated by functions in $\mathcal{A}$. It is then easy to see that the same is true for simple functions and since these are dense in $L^p(X, \mathcal{B}(X), \mu)$, we conclude that $\mathcal{A}$ is in fact dense in $L^p(X, \mathcal{B}(X), \mu)$.
