The following procedures compute the Euclidean distance between two fingerprints, the Euclidean norm, and the normalized version of a fingerprint. All three are straightforward.

        ;; The distance between two fingerprints.
      
        (define (fingerprint-distance x y)
          (let* ((v1 (fingerprint:asVector x))
                 (v2 (fingerprint:asVector y))
                 (n (vector-length v1)))
            (assert (= n (vector-length v2)))
            (do ((i 0 (+ i 1))
                 (sum 0
                      (+ sum (let ((diff (- (vector-ref v1 i)
                                            (vector-ref v2 i))))
                               (* diff diff)))))
                ((= i n)
                 (sqrt sum)))))
      
        ;; The norm of a fingerprint's vector.
      
        (define (fingerprint-norm v)
          (define (square x) (* x x))
          (let ((n (vector-length v)))
            (do ((i 0 (+ i 1))
                 (sum 0 (+ sum (square (vector-ref v i)))))
                ((= i n)
                 (sqrt sum)))))
      
        ;; Given a vector, returns a vector in the same direction
        ;; with a standard length.
      
        (define (fingerprint-normalized v)
          (let* ((norm (fingerprint-norm v))
                 (x (/ normalized-length norm))
                 (n (vector-length v))
                 (v2 (make-vector n)))
            (if (= 0.0 norm)
                v
                (do ((i 0 (+ i 1)))
                    ((= i n)
                     v2)
                  (vector-set! v2 i (* x (vector-ref v i)))))))
      
        )
    

For debugging: Click here to validate.