diff --git a/VL2/VL2_document_structure.tex b/VL2/VL2_document_structure.tex index a215ba0..f7b2dc7 100644 --- a/VL2/VL2_document_structure.tex +++ b/VL2/VL2_document_structure.tex @@ -57,6 +57,7 @@ \subsection{Partial application} \slide{./content/VL2_currying6.tex} +\slide{./content/VL2_currying6.2.tex} \subsection{Curry \ifger{und}{and} Uncurry} \slide{./content/VL2_currying7.tex} diff --git a/VL2/content/VL2_currying1.tex b/VL2/content/VL2_currying1.tex index faff2e0..14678ab 100644 --- a/VL2/content/VL2_currying1.tex +++ b/VL2/content/VL2_currying1.tex @@ -10,4 +10,4 @@ addInt x y = x + y addInt :: (Int, Int) -> Int addInt (x, y) = x + y \end{haskellcode} -\ifger{was im Grunde der Sache sogar recht nahe kommt.}{which is actually pretty close.} \ No newline at end of file +\ifger{was im Grunde der Sache sogar recht nahe kommt. Denn die Beziehung beider Schreibweisen ist eigentlich schon \textbf{Currying}.}{which is actually pretty close. Because the connection between both syntax is exactly that: \textbf{currying}.} \ No newline at end of file diff --git a/VL2/content/VL2_currying3.tex b/VL2/content/VL2_currying3.tex index b0c7131..86174ef 100644 --- a/VL2/content/VL2_currying3.tex +++ b/VL2/content/VL2_currying3.tex @@ -4,7 +4,7 @@ $f(x, y) = y / x$ \\ \pause \ifger{Um diese Funktion für $x = 2$ und $y = 3$ zu berechnen würden wir einfach einsetzen:}{In order to evaluate the function for $x = 2$ and $y = 3$ we would do:}\\ -$f(2, 3) = 2 / 3$\\ +$f(2, 3) = 3 / 2$\\ \ifger{und fertig sein.}{and be done.} \vspace{\baselineskip} \\ diff --git a/VL2/content/VL2_currying6.2.tex b/VL2/content/VL2_currying6.2.tex new file mode 100644 index 0000000..0cc6a52 --- /dev/null +++ b/VL2/content/VL2_currying6.2.tex @@ -0,0 +1,15 @@ +\ifger{Wer es unbedingt wissen will, der Grund warum wir \hinline{x} auslassen können ist, dass}{The reason we can omit the \hinline{x} here is that} +\begin{haskellcode} +f x y z = ... +\end{haskellcode} +\ifger{mehr oder weniger nur syntax sugar ist für}{is more or less just syntax sugar for} +\begin{haskellcode} +f = \x -> (\y -> (\z -> ... )) -- right-associative, ofc +\end{haskellcode} +\ifger{D.h. wir hätten auch folgendes schreiben können:}{That means we could have said:} +\begin{haskellcode} +addTwo :: Int -> Int +addTwo = \x -> (addInt 2) x +-- instead of +addTwo x = (addInt 2) x +\end{haskellcode} \ No newline at end of file diff --git a/VL2/content/VL2_currying6.tex b/VL2/content/VL2_currying6.tex index c2e8b1a..69f0355 100644 --- a/VL2/content/VL2_currying6.tex +++ b/VL2/content/VL2_currying6.tex @@ -7,13 +7,8 @@ addInt x y = x + y addTwo :: Int -> Int addTwo = addInt 2 \end{haskellcode} -\ifger{Warum haben wir nicht \hinline{addTwo x = ...} geschrieben? Wieso sollten wir? Wir haben \hinline{addInt} ein Argument übergeben, also ist die Arität (im Beispiel vorher Dimension) einer weniger und damit ist noch ein Argument notwendig um den endgültigen Wert zu bekommen.}{You probably noticed that we did not write \hinline{addTwo x = ...}, but why would we? We gave \hinline{addInt} one argument, so the arity (we called it dimension in the gemoetrical example) is one less, but there is still one parameter left we can pass in.} -\pause -\ifger{Der Grund warum wir \hinline{x} auslassen können ist, dass}{The reason we can omit the \hinline{x} here is that} -\begin{haskellcode} -f x y z = ... -\end{haskellcode} -\ifger{nur syntax sugar ist für}{is just syntax sugar for} -\begin{haskellcode} -f = \x -> (\y -> (\z -> ... )) -- right-associative, ofc -\end{haskellcode} \ No newline at end of file +\ifger{Warum haben wir nicht \hinline{addTwo x = ...} geschrieben? Wieso sollten wir? Wir haben \hinline{addInt} ein Argument übergeben, also ist die Arität (im Beispiel vorher Dimension) einer weniger und damit ist noch ein Argument notwendig um den endgültigen Wert zu bekommen. +\vspace{\baselineskip}\\ +Oder in anderen Worten: wir haben der Zwischenfunktion, die Currying für uns erstellt hat, lediglich den Namen \hinline{addTwo} gegeben.}{You probably noticed that we did not write \hinline{addTwo x = ...}, but why would we? We gave \hinline{addInt} one argument, so the arity (we called it dimension in the gemoetrical example) is one less, but there is still one parameter left we can pass in. +\vspace{\baselineskip}\\ +Or in other words: we just gave the intermediate function that currying created for us the name \hinline{addTwo}. That's it.}\vspace{\baselineskip}\\ \ No newline at end of file