Learn R Programming

tinylens (version 0.1.0)

over_map: Map a function over a list lens

Description

Apply a function to each element of a list returned by a lens. Using over in such cases would require a "lifted" function, which is often unergonomic.

Usage

over_map(d, l, f)

Value

The modified data structure

Arguments

d

The data structure to modify

l

The list-returning lens to apply

f

The function to apply to each element of the list

Examples

Run this code
d <- list(list(a = 1, b = 2), list(a = 4, b = 9))
l <- map_l(index_l("a"))
over_map(d, l, sqrt)

Run the code above in your browser using DataLab