瀏覽代碼

Improve and restructure currying slides

master
Julian Ospald 9 年之前
父節點
當前提交
ca934d2391
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 220CD1C5BDEED020
共有 5 個檔案被更改,包括 23 行新增12 行删除
  1. +1
    -0
      VL2/VL2_document_structure.tex
  2. +1
    -1
      VL2/content/VL2_currying1.tex
  3. +1
    -1
      VL2/content/VL2_currying3.tex
  4. +15
    -0
      VL2/content/VL2_currying6.2.tex
  5. +5
    -10
      VL2/content/VL2_currying6.tex

+ 1
- 0
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}


+ 1
- 1
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.}
\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}.}

+ 1
- 1
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}
\\


+ 15
- 0
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}

+ 5
- 10
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}
\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}\\

Loading…
取消
儲存