(declare (unit util-bst-ldict)) (import duck) (module* util-bst-ldict #:doc ("Reimplementation of old list-based symbol dictionary using new BST backend.") ( make-ldict ldict? ldict-empty? ldict-contains? ldict-ref ldict-remove ldict-set ldict-keys ldict-map ldict-filter ldict-reduce ldict-equal? ) (import scheme util-bst util-proc) (define (symbolstring a) (symbol->string b))) (define (make-ldict) (make-bst 'symbol eq? symbol=? 2) proc)) (index? ((procedure-arity>=? 3) proc))) (bst-map-bst ld (lambda (k v) (let ((r (if both? (if index? (proc k v i) (proc k v)) (proc v)))) (set! i (add1 i)) r))))) (define (ldict-filter pred? ld) (bst-filter ld pred?)) (define (ldict-reduce init proc ld) (bst-reduce ld proc init)) (define ldict-equal? bst-equal?) )