-
-
Save sritchie/5b33bae6bb3e28b7f815 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def mat [[1 2 3 4 5] | |
[6 7 8 9 10] | |
[11 12 13 14 15] | |
[16 17 18 19 20]]) | |
(defn walk-matrix | |
"Walks along the rows and columns of a matrix at the given window | |
size, returning all (window x window) snapshots." | |
[matrix window] | |
(letfn [(walk-rows [rows] | |
(apply map vector | |
(map #(partition window 1 (matrix %)) | |
rows)))] | |
(reduce conj (map (comp vec walk-rows) | |
(partition window 1 (range (count matrix))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment