Given the function
$$
f(x)=\left\{\begin{array}{lc}
-x, & 0 \leqslant x \leqslant 1, \\
1+x, & -1 \leqslant x<0 .
\end{array}\right.
$$

Then its inverse function is $\qquad$
$$
\text { 2. } f^{-1}(x)=\left\{\begin{array}{l}
x-1, x \in[0,1), \\
-x, x \in[-1,0]
\end{array}\right.
$$

Draw the graph of the function $f(x)$. Since its graph is symmetric to the graph of its inverse function about $y=x$, we can obtain the graph of $f^{-1}(x)$, and thus get the analytical expression of the function.
