more hash functions
This commit is contained in:
parent
1590687e7a
commit
5310956848
|
@ -127,10 +127,10 @@ The JobManager then performs the job and, when finished, asserts (job-finished I
|
|||
(define (word-count-increment [h : WordCount]
|
||||
[word : String]
|
||||
-> WordCount)
|
||||
(hash-update h
|
||||
word
|
||||
add1
|
||||
#;(λ x 0)))
|
||||
(hash-update/failure h
|
||||
word
|
||||
add1
|
||||
(lambda () 0)))
|
||||
|
||||
(define (count-new-words [word-count : WordCount]
|
||||
[words : (List String)]
|
||||
|
@ -168,9 +168,7 @@ The JobManager then performs the job and, when finished, asserts (job-finished I
|
|||
(define wc (count-new-words (ann (hash) WordCount) (string->words data)))
|
||||
(set! state (finished wc))]
|
||||
[(reduce-work (bind left WordCount) (bind right WordCount))
|
||||
;; TODO - this kind of hash-union
|
||||
#;(define wc (hash-union left right #:combine +))
|
||||
(define wc left)
|
||||
(define wc (hash-union/combine left right +))
|
||||
(set! state (finished wc))])
|
||||
(set! status IDLE)]
|
||||
[#t
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
hash-ref
|
||||
hash-has-key?
|
||||
hash-update
|
||||
(typed-out [[hash-update/failure- : (∀ (K V) (→fn (Hash K V) K (→fn V V) (→fn V) (Hash K V)))]
|
||||
hash-update/failure])
|
||||
hash-remove
|
||||
hash-map
|
||||
hash-keys
|
||||
|
@ -15,6 +17,8 @@
|
|||
hash-count
|
||||
hash-empty?
|
||||
hash-union
|
||||
(typed-out [[hash-union/combine- : (∀ (K V) (→fn (Hash K V) (Hash K V) (→fn V V V) (Hash K V)))]
|
||||
hash-union/combine])
|
||||
)
|
||||
|
||||
(require "core-types.rkt")
|
||||
|
@ -67,3 +71,9 @@
|
|||
[hash-union : (∀ (K1 V1 K2 V2) (→fn (Hash K1 V1) (Hash K2 V2) (Hash (U K1 K2) (U V1 V2))))]
|
||||
;; TODO - hash-union with #:combine
|
||||
)
|
||||
|
||||
(define- (hash-update/failure- h k u err)
|
||||
(#%app- hash-update- h k u err))
|
||||
|
||||
(define- (hash-union/combine- h1 h2 combine)
|
||||
(#%app- hash-union- h1 h2 #:combine combine))
|
||||
|
|
Loading…
Reference in New Issue