Rename hash pluck lens
This commit is contained in:
parent
e00482f85b
commit
9488650021
|
@ -1,15 +1,16 @@
|
|||
#lang racket/base
|
||||
|
||||
(provide hash-pluck-lens)
|
||||
(provide hash-pick-lens)
|
||||
|
||||
(require racket/list
|
||||
lens/base/main
|
||||
"hash.rkt"
|
||||
"join.rkt")
|
||||
|
||||
(module+ test
|
||||
(require rackunit))
|
||||
|
||||
(define (hash-pluck-lens . ks)
|
||||
(define (hash-pick-lens . ks)
|
||||
(apply lens-join/hash
|
||||
(append-map
|
||||
(λ (k)
|
||||
|
@ -17,8 +18,8 @@
|
|||
ks)))
|
||||
|
||||
(module+ test
|
||||
(check-equal? (lens-view (hash-pluck-lens 'a 'c) (hash 'a 1 'b 2 'c 3))
|
||||
(check-equal? (lens-view (hash-pick-lens 'a 'c) (hash 'a 1 'b 2 'c 3))
|
||||
(hash 'a 1 'c 3))
|
||||
(check-equal? (lens-set (hash-pluck-lens 'a 'c) (hash 'a 1 'b 2 'c 3) (hash 'a 4 'c 5))
|
||||
(check-equal? (lens-set (hash-pick-lens 'a 'c) (hash 'a 1 'b 2 'c 3) (hash 'a 4 'c 5))
|
||||
(hash 'a 4 'b 2 'c 5))
|
||||
)
|
|
@ -4,13 +4,13 @@
|
|||
|
||||
@title{Viewing a subset of a hash table by key}
|
||||
|
||||
@defmodule[unstable/lens/hash-pluck]
|
||||
@defmodule[unstable/lens/hash-pick]
|
||||
|
||||
@defproc[(hash-pluck-lens [key any/c] ...) lens?]{
|
||||
@defproc[(hash-pick-lens [key any/c] ...) lens?]{
|
||||
Creates a lens that views a subset of the target hash-table with the given
|
||||
@racket[key]s. The view, is another hash-table with only the given keys and
|
||||
their corrosponding values in the target hash-table.
|
||||
@lenses-unstable-examples[
|
||||
(lens-view (hash-pluck-lens 'a 'c) (hash 'a 1 'b 2 'c 3))
|
||||
(lens-set (hash-pluck-lens 'a 'c) (hash 'a 1 'b 2 'c 3) (hash 'a 4 'c 5))
|
||||
(lens-view (hash-pick-lens 'a 'c) (hash 'a 1 'b 2 'c 3))
|
||||
(lens-set (hash-pick-lens 'a 'c) (hash 'a 1 'b 2 'c 3) (hash 'a 4 'c 5))
|
||||
]}
|
|
@ -10,7 +10,7 @@
|
|||
"sublist.rkt"
|
||||
"struct.rkt"
|
||||
"arrow.rkt"
|
||||
"hash-pluck.rkt"
|
||||
"hash-pick.rkt"
|
||||
"stream.rkt"
|
||||
)
|
||||
|
||||
|
@ -24,6 +24,6 @@
|
|||
"sublist.rkt"
|
||||
"struct.rkt"
|
||||
"arrow.rkt"
|
||||
"hash-pluck.rkt"
|
||||
"hash-pick.rkt"
|
||||
"stream.rkt"
|
||||
))
|
||||
|
|
|
@ -19,5 +19,5 @@ this library being backwards-compatible.
|
|||
@include-section["sublist.scrbl"]
|
||||
@include-section["struct.scrbl"]
|
||||
@include-section["arrow.scrbl"]
|
||||
@include-section["hash-pluck.scrbl"]
|
||||
@include-section["hash-pick.scrbl"]
|
||||
@include-section["stream.scrbl"]
|
||||
|
|
Loading…
Reference in New Issue
Block a user