   (:require [k-means.vector :as vector]))
 
 (defn mean-2dvec
-  [v]
+  [^ints v]
   (cond
     (empty? v) v
     :else

  "returns the index of the centroid c closest to vecotr v"
  [c v]
    (for [i c :let [d (distance i v)]] d))

(defn min-distance-p
  "returns the index of the centroid c closest to vecotr v"
  [c v]
    (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"
  [l]
  (map distance l))

(defn cluster
  "take a list of vectors and cluster on centroids c via distance"


(defn group-clusters
  "group a list of cluster groups into one cluster group"
  ([^ints l] (group-clusters l (vector/make-list (count l))))
  ([^ints l ^ints a]
    (cond
      (empty? l) a
      :else
        (recur (rest l) (map into (first l) a)))))

(defn cluster-p
  "take a list of vectors and cluster on centroids c via distance in parallel"
  [^ints l ^floats c]
    (let [clusters (for [i (partition-all (int (/ (count l) (count c))) l) :let [m (future (p :cluster (cluster-m i c)))]] (deref m))]
      (p :group-clusters (group-clusters clusters))))
