db with prim hash - lookup method

This commit is contained in:
erana 2017-03-06 06:45:50 +01:00
parent e8c98e56ff
commit 389467c409
2 changed files with 2 additions and 14 deletions

View File

@ -28,13 +28,7 @@
))
(define (lookup key)
(let ((*result #f))
(do ((i 0 (+ i 1)))
((eq? i (length *db))
*result)
(if (eq? key (car (list-ref *db i)))
(set! *result (cadr (list-ref *db i))))
)))
(cadr (list-ref *db (key->hash key))))
(define (key->hash key)
(let ((*hash 0))

View File

@ -28,13 +28,7 @@
))
(define (lookup key)
(let ((*result #f))
(do ((i 0 (+ i 1)))
((eq? i (length *db))
*result)
(if (eq? key (car (list-ref *db i)))
(set! *result (cadr (list-ref *db i))))
)))
(cadr (list-ref *db (key->hash key)))
(define (key->hash key)
(let ((*hash 0))