provide and document string lenses
This commit is contained in:
parent
bc08f347f7
commit
3c2db6c1a9
|
@ -4,6 +4,7 @@
|
|||
"join.rkt"
|
||||
"list.rkt"
|
||||
"hash.rkt"
|
||||
"string.rkt"
|
||||
"view-set.rkt"
|
||||
"sublist.rkt"
|
||||
"struct.rkt"
|
||||
|
@ -15,6 +16,7 @@
|
|||
"join.rkt"
|
||||
"list.rkt"
|
||||
"hash.rkt"
|
||||
"string.rkt"
|
||||
"view-set.rkt"
|
||||
"sublist.rkt"
|
||||
"struct.rkt"
|
||||
|
|
|
@ -13,6 +13,7 @@ this library being backwards-compatible.
|
|||
@include-section["join.scrbl"]
|
||||
@include-section["list.scrbl"]
|
||||
@include-section["hash.scrbl"]
|
||||
@include-section["string.scrbl"]
|
||||
@include-section["syntax.scrbl"]
|
||||
@include-section["sublist.scrbl"]
|
||||
@include-section["struct.scrbl"]
|
||||
|
|
23
unstable/lens/string.scrbl
Normal file
23
unstable/lens/string.scrbl
Normal file
|
@ -0,0 +1,23 @@
|
|||
#lang scribble/manual
|
||||
|
||||
@(require lens/doc-util/main)
|
||||
|
||||
@title{String Lenses}
|
||||
|
||||
@defproc[(string-ref-lens [i exact-nonnegative-integer?]) lens?]{
|
||||
Returns a lens for viewing the @racket[i]th character of a string.
|
||||
@lenses-unstable-examples[
|
||||
(lens-view (string-ref-lens 2) "abcdef")
|
||||
(lens-set (string-ref-lens 2) "abcdef" #\C)
|
||||
]}
|
||||
|
||||
@defproc[(string-pluck-lens [i exact-nonnegative-integer?]) lens?]{
|
||||
Like @racket[list-refs-lens], but for strings.
|
||||
Equivalent to @racket[(lens-join/string (string-ref-lens i) ...)].
|
||||
@lenses-unstable-examples[
|
||||
(define 1-5-6-lens (string-pluck-lens 1 5 6))
|
||||
(check-equal? (lens-view 1-5-6-lens "abcdefg")
|
||||
"bfg")
|
||||
(check-equal? (lens-set 1-5-6-lens "abcdefg" "BFG")
|
||||
"aBcdeFG")
|
||||
]}
|
Loading…
Reference in New Issue
Block a user