haskell-lectures/VL2/content/VL2_map2.tex

23 lines
650 B
TeX
Raw Normal View History

2015-04-23 19:34:47 +00:00
\ifger{Lösung:}{Solution:}
\begin{haskellcode}
addTwo :: [Int] -> [Int]
2015-05-01 14:42:06 +00:00
addTwo [] = []
addTwo (x:xs) = (x + 2) : addTwo xs
\end{haskellcode}
\pause
2015-04-23 19:34:47 +00:00
\ifger{Jetzt wollen wir jedes Element quadrieren:}{Now we want to square every element:}
\pause
\begin{haskellcode}
square :: [Int] -> [Int]
2015-05-01 14:42:06 +00:00
square [] = []
square (x:xs) = (x * x) : square xs
\end{haskellcode}
\pause
2015-04-23 19:34:47 +00:00
\ifger{Jetzt wollen wir den Betrag jedes Elements:}{Now we want the absolute of every element:}
\begin{haskellcode}
absList :: [Int] -> [Int]
2015-05-01 14:42:06 +00:00
absList [] = []
absList (x:xs) = (abs x) : absList xs
\end{haskellcode}
\pause
2015-04-23 19:34:47 +00:00
\ifger{Fällt etwas auf?}{Do you notice something?}