home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 2: PC
/
frozenfish_august_1995.bin
/
bbs
/
d09xx
/
d0963.lha
/
SIOD
/
scm
/
hash.scm
< prev
next >
Wrap
Text File
|
1993-05-11
|
1KB
|
33 lines
(define vec (make-vector 100 nil))
(define size 100)
(define (collision x y s)
(let* ((y (remainder y size))
(el (vector-ref vec y)))
(cond ((null? el) (vector-set! vec y x))
((eqv? el x) el)
((= y s) 'table-full)
(else (collision x (1+ y) s)))))
(define (hash x)
(let* ((y (remainder (+ (* x 67891) 8763) size))
(el (vector-ref vec y)))
(cond ((null? el) (vector-set! vec y x))
((eqv? el x) el)
(else (collision x (1+ y) y)))))
(define (unhash x)
(let* ((y (remainder (+ (* x 67891) 8763) size))
(el (vector-ref vec y)))
(cond ((null? el) nil)
((eqv? el x) el)
(else (un-collision x (1+ y) y)))))
(define (un-collision x y s)
(let* ((y (remainder y size))
(el (vector-ref vec y)))
(cond ((null? el) nil)
((eqv? el x) el)
((= y s) nil)
(else (un-collision x (1+ y) s)))))