25 lines
1.1 KiB
TeX
25 lines
1.1 KiB
TeX
\ifger{Und jetzt können wir Funktionen verketten, egal wieviele:}{And now you can chain functions together. Not just two! Look:}
|
|
\begin{haskellcode}
|
|
f :: String -> Bool
|
|
f xs = (even . length . (\x -> x ++ "Hello world")) xs
|
|
-- or less ugly
|
|
f xs = even . length . (\x -> x ++ "Hello world") $ xs
|
|
\end{haskellcode}
|
|
% $
|
|
\pause
|
|
\ifger{Ein anderes Beispiel, bei dem Currying tatsächlich relevant ist:}{Another example where currying is actually important:}
|
|
\begin{haskellcode}
|
|
f :: Int -> Bool
|
|
f x = even . (+) 3 . (-) 4 $ x
|
|
|
|
-- why not this?
|
|
f x = even . (+) 3 . (-) $ 4 x
|
|
\end{haskellcode}
|
|
%$
|
|
\pause
|
|
\ifger{Aber es gilt hier einige wichtige Dinge zu beachten:}{So there are a few things that we have to be aware of:}
|
|
\begin{itemize}
|
|
\item \ifger{die Typen müssen passen!}{the types have to fit!}
|
|
\item \ifger{die Arität muss passen!}{the arity has to fit!}
|
|
\end{itemize}
|
|
\ifger{Das klingt anfangs kompliziert, weil es für die gesamte Verkettung gilt, aber man kommt sehr schnell rein.}{That sounds complicated at first, because it counts for the whole composition chain. But you'll get used to it.} |