|
|
@@ -1,14 +1,14 @@ |
|
|
|
\ifger{Um es kurz zu machen, die abstrakte Lösung ist:}{To cut the story short, the abstract solution looks like this:} |
|
|
|
\begin{haskellcode} |
|
|
|
fold :: b -> (a -> b -> b) -> [a] -> b |
|
|
|
fold z f [] = z |
|
|
|
fold z f (x:xs) = x `f` (fold z f xs) |
|
|
|
fold :: (a -> b -> b) -> b -> [a] -> b |
|
|
|
fold f z [] = z |
|
|
|
fold f z (x:xs) = x `f` (fold f z xs) |
|
|
|
\end{haskellcode} |
|
|
|
Whoa! What's going on here?\\ |
|
|
|
\ifger{Schauen wir genauer hin...}{Let's see...} |
|
|
|
\begin{itemizep} |
|
|
|
\item \hinline{z} \ifger{ist was die Funktion zurückgibt, wenn die Liste leer ist}{is what we return if the list is empty} |
|
|
|
\item \hinline{f} \ifger{ist unsere Funktion}{is our function} (\ifger{z.b.}{e.g.} \hinline{(*)} \ifger{oder}{or} \hinline{(+)}) |
|
|
|
\item \hinline{z} \ifger{ist was die Funktion zurückgibt, wenn die Liste leer ist}{is what we return if the list is empty} |
|
|
|
\item \ifger{das letzte Argument ist die eigentliche Liste, auf der wir arbeiten}{and the last remaining argument is the actual list we are working on} |
|
|
|
\end{itemizep} |
|
|
|
\slidep |
|
|
|