You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

15 lines
788 B

  1. \ifger{Und jetzt definieren wir unsere ursprünglichen Funktionen mithilfe von \hinline{map}:}{And now watch this:}
  2. \begin{haskellcode}
  3. addTwo :: [Int] -> [Int]
  4. addTwo xs = map (\x -> x + 2) xs
  5. square :: [Int] -> [Int]
  6. square xs = map (\x -> x * x) xs
  7. absList :: [Int] -> [Int]
  8. absList xs = map (\x -> abs x) xs
  9. -- a haskeller would write, GHCi...
  10. absList = map abs
  11. \end{haskellcode}
  12. \pause
  13. \ifger{Cool, oder? Wir haben jetzt die \textbf{Rekursionsstruktur} herausabstrahiert, weil sie für alle 3 Funktionen dieselbe ist. \hinline{map} ist schon Teil des Standardmoduls \emph{Prelude}.}{Cool, right? So now we have abstracted out the \textbf{recursion pattern} that is all the same for those 3 functions. \hinline{map} is actually part of the standard library (called \emph{Prelude}).}