6.2.901.900
6 Vector lenses
procedure
(vector-ref-lens i) → lens?
i : exact-nonnegative-integer? Returns a lens that views an element of a vector.
Examples:
> (lens-view (vector-ref-lens 2) #(a b c d)) 'c
> (lens-set (vector-ref-lens 2) #(a b c d) "sea") '#(a b "sea" d)
procedure
(vector-ref-nested-lens i ...) → lens?
i : exact-nonnegative-integer?
Examples:
> (lens-view (vector-ref-nested-lens 2 1) #(a b #(s i) d)) 'i
> (lens-set (vector-ref-nested-lens 2 1) #(a b #(s i) d) "eye") '#(a b #(s "eye") d)
procedure
(vector-pick-lens i ...) → lens?
i : exact-nonnegative-integer?
Examples:
> (define 1-5-6-lens (vector-pick-lens 1 5 6))
> (lens-view 1-5-6-lens #(a b c d e f g)) '#(b f g)
> (lens-set 1-5-6-lens #(a b c d e f g) #(1 2 3)) '#(a 1 c d e 2 3)