ZVON > References > Haskell reference
| Indexes | Syntax | >> Prelude << | Ratio | Complex | Numeric | Ix | Array | List | Maybe | Char | Monad | IO | Directory | System | Time | Locale | CPUTime | Random

Module: Prelude
Function: map
Type: (a -> b) -> [a] -> [b]
Description: returns a list constructed by appling a function (the first argument) to all items in a list passed as the second argument
Related:
Keywords: list calculation, list construction

Example 1

Input: map abs [-1,-3,4,-12]

Output: [1,3,4,12]

Example 2

Input: map reverse ["abc","cda","1234"]

Output: ["cba","adc","4321"]

Example 3

Input: map (3*) [1,2,3,4]

Output: [3,6,9,12]

Example 4

Input: map (recip . negate) [1,4,-5,0.1]

Output: [-1.0,-0.25,0.2,-10.0]

Example 5

Input: map (print) [1,3,5,6,7]

Output: [<<IO action>>,<<IO action>>,<<IO action>>,<<IO action>>,<<IO action>>]