   [c v]
     (for [i c :let [d (distance i v)]] d))
 
+(defn make-vector
+  "create a vector containing n cols"
+  ([n] (make-vector n []))
+  ([n c]
+    (cond
+      (<= n 0) c
+      :else
+        (recur (dec n) (conj c [])))))
+
 (defn cluster
   "take a vector and cluster it via distance"
   [g l c]
-  (println g)
   (cond
-    (empty? g) (recur (hash-set (range 0 (count c))) l c)
-    (not-empty l) (recur (conj (first l) (get g (min-index (min-distance c (first l))))) (rest l) c)
+    (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))
 

(defn -main
  "Main function for k-means"
  [& args]
  (k-means [[1 2] [3 2] [6 3] [1 8] [9 10] [1 4]] 3))


(defn still-moving?
  "Predicate to test if the centroids have not reached equlibrium"
  [t c]
  (= t c))

(defn mean
  "Retrieve the mean value of a list"
