6.3.90.900
Lenses for Generic Collections
(require alexis/collection/lens) | |
package: alexis-collection-lens |
This provides lenses that examine and modify generic collections.
Constructs a lens for a keyed value of an indexable? instance.
Examples:
procedure
index : exact-nonnegative-integer?
Constructs a lens for a single element of a sequence?.
Constructs a lens that maps over sequence? instances.
Examples:
> (lens-view (map-lens (ref-lens 'key)) (list (hash 'key 1 'a 2) (hash 'key 2 'b 3))) #<stream>
> (sequence->list (lens-view (map-lens (ref-lens 'key)) (list (hash 'key 1 'a 2) (hash 'key 2 'b 3)))) '(1 2)
> (sequence->list (lens-set (map-lens (ref-lens 'key)) (list (hash 'key 1 'a 2) (hash 'key 2 'b 3)) (list 100 200))) '(#hash((key . 100) (a . 2)) #hash((key . 200) (b . 3)))
> (sequence->list (lens-transform (map-lens (ref-lens 'key)) (list (hash 'key 1 'a 2) (hash 'key 2 'b 3)) (λ (lst) (map (λ (x) (* 10 x)) lst)))) '(#hash((key . 10) (a . 2)) #hash((key . 20) (b . 3)))
value
A lens for the first element of a sequence?.
A lens for all but the first element of a sequence?.
procedure
n : exact-nonnegative-integer?
Constructs a lens for the first n elements of a
sequence?.
procedure
n : exact-nonnegative-integer?
Constructs a lens for the rest of a sequence? after the first
n elements.
procedure
(subsequence-lens start end) → lens?
start : exact-nonnegative-integer? end : exact-nonnegative-integer?
procedure
(subsequence*-lens start len) → lens?
start : exact-nonnegative-integer? len : exact-nonnegative-integer?
A lens for a subsequence starting at start with length
len elements. The range behavior corresponds to
subsequence*.