<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">Let's abstract out the common pieces! This will be our type signature:
\begin{haskellcode}
filter :: (a -&gt; Bool) -&gt; [a] -&gt; [a]
\end{haskellcode}
Solution?
\pause
\begin{haskellcode}
filter :: (a -&gt; Bool) -&gt; [a] -&gt; [a]
filter f [] = []
filter f (x:xs)
  | f x       = x : filter f xs
  | otherwise = filter f xs
\end{haskellcode}
Again: this function is part of the \emph{Prelude} as well.</pre></body></html>