Skip to content

Instantly share code, notes, and snippets.

@sudodoki sudodoki/vector_stuff.cljs Secret
Last active Aug 29, 2015

Embed
What would you like to do?
(defn averageVectors
"Find average of given vectors"
[vectors]
(let [sum (reduce addVector vectors)
count (count vectors)]
(map #(/ % count) sum)
))
(defn addVector
"Adding two or more vectors"
[& vectors]
(apply #(apply mapv + %&) vectors)
)
(def a (vector 0 1))
(def b (vector 2 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.