diff --git a/guide/english/haskell/map/index.md b/guide/english/haskell/map/index.md new file mode 100644 index 0000000000..d4b8e10575 --- /dev/null +++ b/guide/english/haskell/map/index.md @@ -0,0 +1,36 @@ +--- +title: map function +--- + +## `map` function + +The `map` function is a built-in haskell's function that maps a function to each element of a list and return a new list +with the result. Graphically, it would look like this. +```haskell +map f [1,2,3,4] +-- [f 1, f 2, f 3, f 4] +``` + +## Signature of `map` + +The signature of the map function is as follows +```haskell +map :: (a -> b) -> [a] -> [b] +``` + +## Examples +```haskell +map succ [1..5] +-- [2,3,4,5,6] + +let sample = [(1, 2), (3, 1), (4, 10)] +map fst sample +-- [1,3,4] + +map snd sample +-- [2,1,10] + +import Data.Char (toLower) # to get the toLower +map toLower "HELLO WORLD HASKELL RULEZ!" +-- "hello world haskell rulez!" +```