1
0
Fork 0

Add example on how a Haskeller would write this function

Dieser Commit ist enthalten in:
Julian Ospald 2015-04-19 19:49:56 +02:00
Ursprung 61347e2c8e
Commit 729c460112
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 220CD1C5BDEED020
1 geänderte Dateien mit 2 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -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}).