provide and document hash-filterer-lens etc.
This commit is contained in:
parent
4bca13af48
commit
fc6a88f37a
35
unstable/lens/hash-filterer.scrbl
Normal file
35
unstable/lens/hash-filterer.scrbl
Normal file
|
@ -0,0 +1,35 @@
|
|||
#lang scribble/manual
|
||||
|
||||
@(require lens/private/doc-util/main)
|
||||
|
||||
@title{Filtering hash-tables}
|
||||
|
||||
@defmodule[unstable/lens/hash-filterer]
|
||||
|
||||
@defproc[(hash-filterer-lens/key [keep? (-> any/c boolean?)])
|
||||
(lens/c immutable-hash? immutable?)]{
|
||||
Creates a lens that filters a hash-table to keys that pass the predicate
|
||||
@racket[keep?].
|
||||
@lens-unstable-examples[
|
||||
(lens-view (hash-filterer-lens/key symbol?) (hash 'a 1 "b" 2 'c 3))
|
||||
(lens-set (hash-filterer-lens/key symbol?) (hash 'a 1 "b" 2 'c 3) (hash 'd 4 'e 5))
|
||||
]}
|
||||
|
||||
@defproc[(hash-filterer-lens/value [keep? (-> any/c boolean?)])
|
||||
(lens/c immutable-hash? immutable?)]{
|
||||
Like @racket[hash-filterer-lens/value], but filters based on values that pass
|
||||
@racket[keep?], not keys.
|
||||
@lens-unstable-examples[
|
||||
(lens-view (hash-filterer-lens/value number?) (hash 'a 1 'b "two" 'c 3))
|
||||
(lens-set (hash-filterer-lens/value number?) (hash 'a 1 'b "two" 'c 3) (hash 'd 4))
|
||||
]}
|
||||
|
||||
@defproc[(hash-filterer-lens [keep? (-> any/c any/c boolean?)])
|
||||
(lens/c immutable-hash? immutable?)]{
|
||||
Creates a lens that filters a hash-table by the predicate @racket[keep?], which
|
||||
takes the key and the value as its two arguments.
|
||||
@lens-unstable-examples[
|
||||
(lens-view (hash-filterer-lens =) (hash 1 1.0 2 45 3 3))
|
||||
(lens-set (hash-filterer-lens =) (hash 1 1.0 2 45 3 3) (hash 4 4.0 5.0 5))
|
||||
]}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
#lang reprovide
|
||||
"arrow.rkt"
|
||||
"dict-nested.rkt"
|
||||
"hash-filterer.rkt"
|
||||
"if.rkt"
|
||||
"isomorphism.rkt"
|
||||
"join-assoc.rkt"
|
||||
|
|
|
@ -14,6 +14,7 @@ this library being backwards-compatible.
|
|||
@(include-sections
|
||||
"arrow.scrbl"
|
||||
"dict-nested.scrbl"
|
||||
"hash-filterer.scrbl"
|
||||
"if.scrbl"
|
||||
"isomorphism.scrbl"
|
||||
"join-assoc.scrbl"
|
||||
|
|
Loading…
Reference in New Issue
Block a user