djb2   xtlang


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

Implementation

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


Back to Index