haskell-lectures/VL2/content/VL2_map1.tex

7 lines
366 B
TeX

Let's say we have a list of \hinline{Int} and want to add \hinline{2} to every element of the list.
\begin{haskellcode}
addTwo :: [Int] -> [Int]
addTwo ... ?
\end{haskellcode}
\pause
\textbf{Exercise:} Find the answer! 5 minutes time, remember the \emph{cons} operator \hinline{(:)}, pattern matching on lists and ofc recursion! Start with the case of an empty list.