haskell-lectures/VL2/content/VL2_composition1.tex

21 lines
1.0 KiB
TeX
Raw Normal View History

2015-04-23 20:57:25 +00:00
\ifger{Wieso haben wir uns so lange mit Currying aufgehalten? Nun, es ist wie gesagt sehr wichtig für \emph{Funktionskomposition}. Sie zählt ebenfalls zu den fundamentalen Basiskonzepten der funktionalen Programmierung.}{So why did we just bother so long with explaining currying? It's because it's very important for \emph{function composition}. Which again is also one of the fundamental concepts of functional programming.}
\vspace{\baselineskip}
\\
2015-04-23 20:57:25 +00:00
\ifger{Aus der Mathematik wissen wir bereits, dass:}{From maths we already know that:}\\
$(g \circ f)(x) = g(f(x))$
\vspace{\baselineskip}
\\
\pause
2015-04-23 20:57:25 +00:00
\ifger{Und das ist praktisch schon alles. Wir machen dasselbe in Haskell:}{And that's basically it. We do the same in haskell, it looks like this:}
\begin{haskellcode}
composedFunction x = (f . g) x
-- same as above... everything on the right side of $
-- is evaluated first
composedFunction x = f . g $ x
-- and same again, remember that 'f x ='
-- is just syntax sugar
-- omitting the x here is also called eta reduction
composedFunction = f . g
\end{haskellcode}