Could you explain to me how to solve this exercise? $$f\colon \mathbb{R}^2 \ \rightarrow \mathbb{R}$$
$$f(x,y) = \begin{cases} 1, \ \ \ \ \ \text{for} \ x \ge 0, \ x \le y < x+1 \\ -1, \ \ \text{for} \ x \ge 0, \ x+1 \le y<x+2 \\ 0 \ \ \ \ \ \ \ \text{elsewhere}\end{cases}$$
How to compute $$\int_{\mathbb{R}} \left(\int_{\mathbb{R}} f(x,y)dx \right)dy?$$
Let $\phi_y(x) = f(x,y) $. Then $\phi_y(x) =1$ when $x \ge 0$ and $y-1 < x \le y$, $\phi_y(x) =-1$ when $x \ge 0$ and $y-2 < x \le y-1$ and zero otherwise.
Hence if $y<0$, we have $\phi_y(x) =0$.
If $y \in [0,1)$, we have $\phi_y(x) =1$ when $x \in (0,y]$, and $0$ otherwise.
If $y \in [1,2)$, we have $\phi_y(x) =-1$ when $x \in (0,y-1]$, $\phi_y(x) =1$ when $x \in (y-1,y]$, and $0$ otherwise.
If $y \ge 2$, we have $\phi_y(x) =-1$ when $x \in (y-2,y-1]$, $\phi_y(x) =1$ when $x \in (y-1,y]$, and $0$ otherwise.
Now compute $\int_\mathbb{R} \phi_y(x) dx$ for each of these four cases. Then integrate the result.