 
 (defn cluster
   "take a vector and cluster it via distance"
-  [g l c]
-  (cond
-    (nil? g) (recur (make-vector (count c)) l c)
-    (not-empty l)
-      (let [i (min-index (min-distance c (first l)))]
-        (recur (assoc g i (conj (nth g i) (first l))) (rest l) c))
-    :else
-    g))
+  ([g l c] (cluster g l c (make-vector (count c))))
+  ([g l c a]
+    (cond
+      (nil? g) (recur (make-vector (count c)) l c (make-vector (count c)))
+      (not-empty l)
+        (let [i (min-index (min-distance c (first l)))]
+          (recur g (rest l) c (assoc a i (conj (nth a i) (first l)))))
+      :else
+      a)))
 
 (defn min-vector
   "Chooses the smallest vector in a set of vectors"

    (k-means l k (choose-initial-centroids l k) (make-vector k) max-iterations))
  ([l k c g max-iterations]
    (let [t c g (cluster g l c) c (mean-centroids g)]
      (println t c (= t c))
      ; (println (still-moving? t c))
      (cond
        (> 0 max-iterations) g

(defn -main
  "Main function for k-means"
  [& args]
  (let [c (k-means (make-vector-rand 5000) 5 100)] (println c)))
