Skip to content

Instantly share code, notes, and snippets.

Last active Dec 21, 2015
What would you like to do?
substract 2 vectors in clojure
(defn minus [v1 v2]
"substract 2 vectors, v2 must be a subset of v1"
(reduce (fn [acc v]
(let [index (.indexOf acc v)]
(into (subvec acc 0 index) (subvec acc (inc index))))) v1 v2))
(minus [:c :a :b :b :a :a :b] [:a :a :b :a]) ; [:c :b :b]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment