haskell-lectures/VL2/content/VL2_map4.tex
Julian Ospald e9374aed1f
VL2: Restructure files, make the latex code more modular
Also added a few more section to make beamer and article more
compatible.
2015-04-20 18:06:58 +02:00

15 lines
491 B
TeX

And now watch this:
\begin{haskellcode}
addTwo :: [Int] -> [Int]
addTwo xs = map (\x -> x + 2) xs
square :: [Int] -> [Int]
square xs = map (\x -> x * x) xs
absList :: [Int] -> [Int]
absList xs = map (\x -> abs x) xs
-- a haskeller would write, GHCi...
absList = map abs
\end{haskellcode}
\pause
Cool, right? So now we have abstracted out the \textbf{recursion pattern} that is all the same for those 3 functions. \code{map} is actually part of the standard library (called \emph{Prelude}).