001  (ns org.clojars.punit-naik.clj-ml.utils.geometry)
002  
003  (def distance-fn-assertion-error-string "The number of coordinates/dimensions of the two points are not equal")
004  
005  (defn distance
006    "Calculates distance between two points in space
007     A point can be described as a vector/list of [an, bn, cn, .... , zn]
008     The distance between two points [a1, b1, c1, .... , z1] and [a2, b2, c2, .... , z2] will be:
009     square root of [(a2 - a1)^2 + (b2 - b1)^2 + (c2 - c1)^2 + .... + (z2 - z1)^2]"
010    [point-1 point-2]
011    (if (= (count point-1)
012           (count point-2))
013      (->> point-1
014           (map
015            #(Math/pow (- %1 %2) 2)
016            point-2)
017           (reduce +)
018           Math/sqrt)
019      (throw
020       (AssertionError. distance-fn-assertion-error-string))))