I have the following question for a seminar and cannot find the relevant information to solve it.
Solve the integral for all $a \in \mathbb R$ $$I(a)=\int_0^1 |x-a| \, {\rm d} x$$
I understand that I have to treat the absolute value of the function $f(x)=|x-a|$ depending on the when $x$ is less or more then $a$, if $a$ had a defined value I could have solved this, but now im stuck because I dont know how to relate its unspecified value to find a solution for the integral.
Any help is appreciated that'll point me in the right direction.

Compute the integral for $a < 0$, $a \in [0,1]$ and $a > 1$. The solution is
$$I (a) = \begin{cases} \frac12 - a & \text{ if } a < 0\\\\ \frac12 - a + a^2 & \text{ if } a \in [0,1]\\\\ a - \frac12 & \text{ if } a > 1\end{cases}$$