On this page:
string-ref-lens
string-pick-lens
6.2.901.900

7 String Lenses

procedure

(string-ref-lens i)  lens?

  i : exact-nonnegative-integer?
Returns a lens for viewing the ith character of a string.

Examples:

> (lens-view (string-ref-lens 2) "abcdef")

#\c

> (lens-set (string-ref-lens 2) "abcdef" #\C)

"abCdef"

Like list-refs-lens, but for strings. Equivalent to (lens-join/string (string-ref-lens i) ...).

Examples:

> (define 1-5-6-lens (string-pick-lens 1 5 6))
> (lens-view 1-5-6-lens "abcdefg")

"bfg"

> (lens-set 1-5-6-lens "abcdefg" "BFG")

"aBcdeFG"