concatMap package:base

Map a function over all the elements of a container and concatenate the resulting lists.

Examples

Basic usage:
>>> concatMap (take 3) [[1..], [10..], [100..], [1000..]]
[1,2,3,10,11,12,100,101,102,1000,1001,1002]
>>> concatMap (take 3) (Just [1..])
[1,2,3]
Map a function returning a list over a list and concatenate the results. concatMap can be seen as the composition of concat and map.
concatMap f xs == (concat . map f) xs

Examples

>>> concatMap (\i -> [-i,i]) []
[]
>>> concatMap (\i -> [-i, i]) [1, 2, 3]
[-1,1,-2,2,-3,3]
>>> concatMap ('replicate' 3) [0, 2, 4]
[0,0,0,2,2,2,4,4,4]
Given a means of mapping the elements of a structure to lists, computes the concatenation of all such lists in order.

Examples

Basic usage:
>>> biconcatMap (take 3) (fmap digitToInt) ([1..], "89")
[1,2,3,8,9]
>>> biconcatMap (take 3) (fmap digitToInt) (Left [1..])
[1,2,3]
>>> biconcatMap (take 3) (fmap digitToInt) (Right "89")
[8,9]