sdbm   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/core/math.xtm

Implementation

(bind-func sdbm
  (lambda (str:i8*)
    (let ((hash:i64 0)
          (len (strlen str))
          (i 0))
      (dotimes (i len)
        (set! hash (- (+ (convert (pref str i)) (<< hash 6) (<< hash 16)) hash)))
      hash)))


Back to Index