From 2627252b1599e3034c8241474c5bea84654a1a2c Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sat, 2 May 2015 12:51:16 +0200 Subject: [PATCH] Improve currying slide --- VL2/content/VL2_currying5.tex | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/VL2/content/VL2_currying5.tex b/VL2/content/VL2_currying5.tex index 9ef3689..aac0e20 100644 --- a/VL2/content/VL2_currying5.tex +++ b/VL2/content/VL2_currying5.tex @@ -1,6 +1,5 @@ \ifger{D.h. mathematisch gesehen können wir schreiben:}{So in mathematical terms you can say:}\\ $f : A_1 \times ... \times A_n \mapsto B$ -\vspace{\baselineskip} \\ \ifger{wird zu}{gets modified into:}\\ \pause @@ -8,7 +7,7 @@ $f' : A_1 \mapsto (A_2 \mapsto (\ ...\ (A_n \mapsto B)))$ \vspace{\baselineskip} \\ \pause -\ifger{Die Klammern hier sind äußerst wichtig! Currying ist \emph{rechts}-assoziativ, d.h. die folgenden 2 Typsignaturen in Haskell sind äquivalent:}{Did you just notice the braces? They are \textbf{very} important! So, currying is \emph{right}-associative which means that these two signatures are equivalent:} +\ifger{Die Klammern hier sind äußerst wichtig! Currying ist \emph{rechts}-assoziativ, d.h. die folgenden 2 Typsignaturen sind äquivalent:}{The braces are \textbf{very} important! It means currying is \emph{right}-associative and these these two signatures are equivalent:} \begin{haskellcode} f :: Int -> Int -> Int f :: Int -> (Int -> Int) @@ -16,4 +15,7 @@ f :: Int -> (Int -> Int) -- but this is NOT the same f :: (Int -> Int) -> Int \end{haskellcode} -\ifger{Auf der anderen Seite ist Funktionsanwendung \emph{links}-assoziativ, d.h.}{On the other hand function application is \emph{left}-associative, so} \hinline{f 3 2} \ifger{ist nur die Kurzform für}{is just a shorthand of} \hinline{(f 3) 2}. \ifger{Macht Sinn?}{Makes sense?} \ No newline at end of file +\ifger{Auf der anderen Seite ist Funktionsanwendung \emph{links}-assoziativ, d.h.}{On the other hand function application is \emph{left}-associative, so} \hinline{f 3 2} \ifger{ist nur die Kurzform für}{is just a shorthand of} \hinline{(f 3) 2}. +\vspace{\baselineskip} +\\ +\ifger{Also, wenn wir in Haskell scheinbar mehrere Argumente einer Funktion übergeben, steckt immer Currying dahinter. Es erzeugt eine Reihe von (Zwischen-)Funktionen mit jeweils einem Argument und evaluiert diese dann schrittweise.}{So, if we seemingly pass multiple arguments into a function, then that's always currying in disguise. It create those (intermediate) functions, all with one argument only, and then evaluates them stepwise.} \ No newline at end of file