Start reimplementing missing ldict through bst.
This commit is contained in:
parent
33fadab5e7
commit
f5e7dfe055
3 changed files with 22 additions and 0 deletions
|
@ -45,4 +45,7 @@
|
|||
(define (ldict-filter pred? ld)
|
||||
(bst-filter ld pred?))
|
||||
|
||||
(define (ldict-reduce init proc ld)
|
||||
(bst-reduce ld proc init))
|
||||
|
||||
)
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
bst-update
|
||||
|
||||
bst-filter
|
||||
bst-reduce
|
||||
|
||||
util-bst-tests!
|
||||
)
|
||||
|
@ -385,6 +386,15 @@ accept two arguments.")
|
|||
(cons (apply vector (bst-filter-pairs bst pred?))
|
||||
(cddr bst)))))
|
||||
|
||||
(define/doc (bst-reduce bst proc init)
|
||||
("Like generic reduce, the proc gets accumulator, key and value
|
||||
arguments.")
|
||||
(let ((acc init))
|
||||
(bst-iter-kv bst
|
||||
(lambda (kv)
|
||||
(set! acc (proc acc (car kv) (cdr kv)))))
|
||||
acc))
|
||||
|
||||
;; Module self-tests
|
||||
(define (util-bst-tests!)
|
||||
(run-tests
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue