-
-
Save slabko/087020f9914722ce17948578662a816f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(ns edge.transform) | |
(def test-matrix (repeat 9 [1 2 3 4 5 6 7 8 9])) | |
(defn- average-color [colors] | |
(let [s (sum colors) | |
]) | |
(color 2)) | |
(defn avg | |
[numbers] | |
(/ (apply + numbers) (count numbers))) | |
(defn scale-row | |
"Row is a vector that is averaged and scaled into a vector or 'size' items." | |
[target-length row] | |
(let [source-length (count row) | |
scale (/ source-length target-length) | |
row' (partition scale row) | |
target-row (map avg row')] | |
target-row)) | |
(defn scale-matrix [hscale vscale matrix] | |
(map (partial scale-row hscale) (apply map list (map (partial scale-row vscale) matrix))) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(ns edge.transform)
(def test-matrix (repeat 9 [1 2 3 4 5 6 7 8 9]))
(defn- average-color [colors](let [s %28sum colors%29
])
(color 2))
(defn avg
[numbers](/ %28apply + numbers%29 %28count numbers%29))
(defn scale-row
"Row is a vector that is averaged and scaled into a vector or 'size' items."
[target-length row]
(defn scale-matrix [hscale vscale matrix](map %28partial scale-row hscale%29 %28apply map list %28map %28partial scale-row vscale%29 matrix%29%29)
)