map_l {lenses} | R Documentation |
Promote a lens to apply to each element of a list
Description
Create a new lens that views and sets each element of the list.
Usage
map_l(l)
Arguments
l |
the lens to promote |
Details
Uses lapply under the hood for view and mapply under the hood for set. This means that set can be given a list of values to set, one for each element. If the input or update are lists this lens always returns a list. If the input and update are vectors this lens will return a vector.
Examples
(ex <- replicate(10, sample(1:5), simplify = FALSE))
view(ex, map_l(index(1)))
set(ex, map_l(index(1)), 11:20)
[Package lenses version 0.0.3 Index]