The map Function
map :: (a -> b) -> [a] -> [b]
map f xs = [f x | x <- xs]ghci> map squareGt100 [7..12]
[False, False, False, False, True, True]ghci> map (* 2) [1..5] -- multiply each number in the list by 2
[2, 4, 6, 8, 10]
ghci> map not [True, False] -- not function reverses the boolean value
[False, True]
ghci> map reverse ["Cardano", "ADA"] -- reverse a given list (strings are lists of chars)
["onadraC","ADA"]
ghci> map ("Hi, " ++) ["Joe", "Jan"]
["Hi, Joe","Hi, Jan"]Last updated