Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

14 lignes
1.5 KiB

  1. \ifger{Was bedeutet das für uns? Es ermöglicht uns \textbf{partial application}, was bedeutet, dass wir einer Funktion nicht alle Argumente übergeben müssen. Wenn wir ''zu wenig'' Argumente übergeben, wird einfach eine neue Funktion generiert. Z.b. so:}{What does that mean for us? It's not just fun stuff or aesthetic. It allows us to do \textbf{partial application}. That means we do not have to give a function all arguments. If we pass an "insufficient" number of arguments it will just give us a new function! Here:}
  2. \pause
  3. \begin{haskellcode}
  4. addInt :: Int -> Int -> Int
  5. addInt x y = x + y
  6. addTwo :: Int -> Int
  7. addTwo = addInt 2
  8. \end{haskellcode}
  9. \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.
  10. \vspace{\baselineskip}\\
  11. 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.
  12. \vspace{\baselineskip}\\
  13. Or in other words: we just gave the intermediate function that currying created for us the name \hinline{addTwo}. That's it.}\vspace{\baselineskip}\\