Implement the whole ldict constructor.
This commit is contained in:
parent
979615ddfd
commit
a0e0c33d56
1 changed files with 21 additions and 6 deletions
|
@ -25,14 +25,29 @@
|
|||
util-bst
|
||||
util-proc)
|
||||
|
||||
(define (symbol<? a b)
|
||||
(string<? (symbol->string a)
|
||||
(symbol->string b)))
|
||||
(define (ldict<? a b)
|
||||
(if (number? a)
|
||||
(< a b)
|
||||
(string<? (symbol->string a)
|
||||
(symbol->string b))))
|
||||
|
||||
(define (make-ldict)
|
||||
(make-bst 'symbol eq? symbol<?))
|
||||
(define (make-ldict . equality?/pairs)
|
||||
(let ((equality? (if (or (null? equality?/pairs)
|
||||
(not (procedure? (car equality?/pairs))))
|
||||
eq?
|
||||
(car equality?/pairs)))
|
||||
(pairs (if (or (null? equality?/pairs)
|
||||
(procedure? (car equality?/pairs)))
|
||||
'()
|
||||
(car equality?/pairs))))
|
||||
(let loop ((ld (make-bst 'ldict equality? ldict<?))
|
||||
(pairs pairs))
|
||||
(if (null? pairs)
|
||||
ld
|
||||
(loop (ldict-set ld (caar pairs) (cdar pairs))
|
||||
(cdr pairs))))))
|
||||
|
||||
(define ldict? (bst? 'symbol))
|
||||
(define ldict? (bst? 'ldict))
|
||||
|
||||
(define ldict-empty? bst-empty?)
|
||||
(define ldict-contains? bst-contains?)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue