 (defn min-distance-p
   "returns the index of the centroid c closest to vecotr v"
   [c v]
-    (for [i c :let [d (distance-p i v)]] d))
+    (for [i c :let [d (distance-p-m i v)]] d))
+(def min-distance-p-m (memoize min-distance-p))
 
 (defn min-vector
   "Chooses the smallest vector in a set of vectors"

      ; otherwise we continue until the list of vectors is empty
      (not-empty l)
        ; for the vector at the start of the list, choose a centroid which is closest
        (let [i (min-index (p :min-distance (min-distance-p c (first l))))]
          ; append the vector to the smallest distance
          (recur (rest l) c (assoc a i (conj (nth a i) (first l)))))
      :else

  ([c1 c2]
    (->> (map - c1 c2) (map #(* % %)) (reduce +))))


(defn distance-p
  "Implements euclidian distance between two vectors"
  ([c1 c2]
    (->> (pmap - c1 c2) (pmap #(* % %)) (reduce +))))
(def distance-p-m (memoize distance-p))

(defn min-index
  [c]
