Implement missing list->bst.
This commit is contained in:
parent
6999664aa1
commit
6d7639e56d
1 changed files with 13 additions and 0 deletions
|
@ -32,11 +32,14 @@
|
|||
bst-map-list
|
||||
bst-map-dict
|
||||
|
||||
list->bst
|
||||
|
||||
util-bst-tests!
|
||||
)
|
||||
|
||||
(import scheme
|
||||
(chicken condition)
|
||||
(chicken sort)
|
||||
util-tag
|
||||
testing)
|
||||
|
||||
|
@ -334,6 +337,16 @@
|
|||
(loop (cddr n))))
|
||||
#f))))
|
||||
|
||||
(define/doc (list->bst lst subtag EQ? <?)
|
||||
("Converts list of pairs into BST dictionary.")
|
||||
(kvv->bst
|
||||
(cons TAG-KVV
|
||||
(cons (list->vector
|
||||
(sort lst (lambda (akv bkv)
|
||||
(<? (car akv) (car bkv)))))
|
||||
(cons subtag
|
||||
(cons EQ? <?))))))
|
||||
|
||||
;; Module self-tests
|
||||
(define (util-bst-tests!)
|
||||
(run-tests
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue