2015-04-23 19:34:47 +00:00
|
|
|
\ifger{Lösung:}{Solution:}
|
2015-04-19 22:32:50 +00:00
|
|
|
\begin{haskellcode}
|
|
|
|
addTwo :: [Int] -> [Int]
|
2015-05-01 14:42:06 +00:00
|
|
|
addTwo [] = []
|
2015-04-19 22:32:50 +00:00
|
|
|
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:}
|
2015-04-19 22:32:50 +00:00
|
|
|
\pause
|
|
|
|
\begin{haskellcode}
|
|
|
|
square :: [Int] -> [Int]
|
2015-05-01 14:42:06 +00:00
|
|
|
square [] = []
|
2015-04-19 22:32:50 +00:00
|
|
|
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:}
|
2015-04-19 22:32:50 +00:00
|
|
|
\begin{haskellcode}
|
|
|
|
absList :: [Int] -> [Int]
|
2015-05-01 14:42:06 +00:00
|
|
|
absList [] = []
|
2015-04-19 22:32:50 +00:00
|
|
|
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?}
|