   "Iterates across the supplied two dimensional matrix, returning a
   lazy sequence of 2-element vectors of the form `[matrix entry,
   neighbor-seq]`. Neighbors outside the matrix are reported as
-  nil. For example:
+  nil. 
 
+  Example usage:
     (def test-matrix [[:0 :1 :2 :3]
                       [:4 :5 :6 :7]
                       [:8 :9 :a :b]
                       [:c :d :e :f]])
 
     (first (neighbor-scan 1 test-matrix))
-    ;=> [:0 ((nil nil nil) (nil :1) (nil :4 :5))]"
-
+       => [:0 ((nil nil nil) (nil :1) (nil :4 :5))]"
   [num-neighbors mat]
   {:pre [(> (count mat)
             (inc (* 2 num-neighbors)))]}

(ns forma.matrix.walk
  (:use cascalog.api
        [forma.utils :only (nth-in)]
        [forma.matrix.utils :only (insert-into-val
                                  insert-at)]))

(defn walk-matrix
  "Walks along the rows and columns of a matrix at the given window
  size, returning all (window x window) snapshots."
  [m window]
  (mapcat (comp (partial apply map vector)
                (partial map (partial partition window 1)))

           (apply concat)
           (filter (complement nil?))
           (apply f)))))
