Compose two lenses to produce a new lens which represents focussing first with the first lens, then with the second. A view using the resulting composite lens will first view using the first, then the second, while an set will view via the first lens, set into the resulting piece with the second, and then replace the updated structure in the first with set. Lens composition is analogous to the . syntax of object-oriented programming or to a flipped version of function composition.

l %.% m

Arguments

l

the first lens (or an oscope)

m

the second lens

Examples

lst <- list(b = c(3,4,5)) lns <- index_l("b") %.% index_l(2) lst %>% view(lns) # returns 4
#> [1] 4
lst %>% set(lns, 1) # returns list(b = c(3,2,5))
#> $b #> [1] 3 1 5 #>
lst # returns list(b = c(3,4,5))
#> $b #> [1] 3 4 5 #>