document and provide string-split-lens
This commit is contained in:
parent
906ff420c6
commit
27117dd557
|
@ -6,6 +6,7 @@
|
|||
"arrow.rkt"
|
||||
"isomorphism.rkt"
|
||||
"mapper.rkt"
|
||||
"string-split.rkt"
|
||||
)
|
||||
|
||||
(provide (all-from-out "syntax.rkt"
|
||||
|
@ -14,4 +15,5 @@
|
|||
"arrow.rkt"
|
||||
"isomorphism.rkt"
|
||||
"mapper.rkt"
|
||||
"string-split.rkt"
|
||||
))
|
||||
|
|
|
@ -15,3 +15,4 @@ this library being backwards-compatible.
|
|||
@include-section["arrow.scrbl"]
|
||||
@include-section["isomorphism.scrbl"]
|
||||
@include-section["mapper.scrbl"]
|
||||
@include-section["string-split.scrbl"]
|
||||
|
|
26
unstable/lens/string-split.scrbl
Normal file
26
unstable/lens/string-split.scrbl
Normal file
|
@ -0,0 +1,26 @@
|
|||
#lang scribble/manual
|
||||
|
||||
@(require lens/doc-util/main)
|
||||
|
||||
@title{Splitting Strings}
|
||||
|
||||
@defmodule[unstable/lens/string-split]
|
||||
|
||||
@defproc[(string-split-lens [sep (or/c string? char? regexp?)]) lens?]{
|
||||
Creates a lens that splits a string into multiple pieces like
|
||||
@racket[regexp-split] or @racket[string-split].
|
||||
@lenses-unstable-examples[
|
||||
(lens-view (string-split-lens ",") "a,b,c")
|
||||
(lens-set (string-split-lens ",") "a,b,c" '("1" "2" "3"))
|
||||
]
|
||||
Lenses created by @racket[string-split-lens] do not trim strings first, so that
|
||||
when viewing a target that either starts or ends with something matching
|
||||
@racket[sep], the view will include empty strings as the first or last element,
|
||||
which is consistant with @racket[regexp-split] or @racket[string-split] with
|
||||
@racket[#:trim? #f]. This is also more useful when using @racket[lens-set].
|
||||
@lenses-unstable-examples[
|
||||
(lens-view (string-split-lens ",") ",b,c")
|
||||
(lens-set (string-split-lens ",") ",b,c" '("a" "b" "c"))
|
||||
(lens-view (string-split-lens ",") "a,b,c,")
|
||||
(lens-set (string-split-lens ",") "a,b,c," '("a" "b" "c" "d"))
|
||||
]}
|
Loading…
Reference in New Issue
Block a user