Browse Source

Add example on how a Haskeller would write this function

stripped-german
Julian Ospald 9 years ago
parent
commit
729c460112
No known key found for this signature in database GPG Key ID: 220CD1C5BDEED020
1 changed files with 2 additions and 0 deletions
  1. +2
    -0
      VL2.tex

+ 2
- 0
VL2.tex View File

@@ -494,6 +494,8 @@ square xs = map (\x -> x * x) xs

absList :: [Int] -> [Int]
absList xs = map (\x -> abs x) xs
-- a haskeller would write, GHCi...
absList = map abs
\end{haskellcode}
\pause
Cool, right? So now we have abstracted out the \textbf{recursion pattern} that is all the same for those 3 functions. \code{map} is actually part of the standard library (called \emph{Prelude}).


Loading…
Cancel
Save