Continuous function $f$ on $\mathbb R $ such that $f \notin L^1 (\mathbb R)$ but $f \in L^1([a,b]), a< b $ Give an example of a continuous function $f$ on $\mathbb R $ such that $f \notin L^1 (\mathbb R)$ but $f \in L^1([a,b]), a< b $
If $f \in L^1([a,b]), a< b$ that would mean that $$\int_{a}^{b}|f(x)|dx < \infty \text{ but $f \notin L^1 (\mathbb R)$ means} \int_{\mathbb R}|f(x)|dx\to \infty \text { or undefined.}$$
I feel like there are many examples for this, like $f(x)=x$, but this was given on a exam, so I think I am not understanding this correctly, what are your guys' thoughts on this? 
Also the second part of the question was to give an example of a continuous function $f$ on $\mathbb R $ such that $f$ is Reiman integrable on $\mathbb R$ but $f \notin L^1 (\mathbb R)$ . Now this seems like it is impossible to me. We have done the other way around in class, but this I just don't know at all how I would go about, maybe constructing a set that satisfies this. Help is needed, very thankful for insight.  

By definition, a function is Lebesgue integrable on $\mathbb R$(i.e. $\in L^1(\mathbb R)$ if its modulus is Lebesgue integrable. (Improper) Riemann integrability on $\mathbb R$, on the other hand is defined as existence of the limit
$$\lim_{a\rightarrow -\infty}\lim_{b\rightarrow \infty} \int _a^b f(x)dx,$$
where the integral $\int _a^b f(x)dx$ is a proper Riemann integral.
So we're looking for a function where $|f|$ makes some problems when integrating, but $f$ does not. 
The alternating harmonic series $\sum_{n=1}^\infty (-1)^n \frac{1}{n}$ is a convergent series, but the harmonic series $\sum_{n=1}^\infty \frac{1}{n}$ does not converge to a finite value.
Thus $$f(x)= \begin{cases}(-1)^n \frac{1}{n}, \mbox {if  }n\leq x < n +1\\ 0, \mbox{otherwise} \end{cases},$$
is a function which is Riemann integrable, but its modulus $|f(x)|= \begin{cases} \frac{1}{n}, \mbox {if  }n\leq x < n +1\\ 0, \mbox{otherwise} \end{cases},$ is neither Riemann nor Lebesgue integrable. Thus, $f \notin L^1(\mathbb R)$.
