Skip to content

Instantly share code, notes, and snippets.

@aib
Created September 19, 2012 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aib/3749769 to your computer and use it in GitHub Desktop.
Save aib/3749769 to your computer and use it in GitHub Desktop.
(defn coll-eq
"Recursively applies a binary predicate to two colls (of colls etc.) and returns the AND of the result."
[eq-fn x y]
(let [all (partial every? identity)
all-eq (comp all (partial map (partial coll-eq eq-fn)))]
(if (and (coll? x) (coll? y))
(all-eq x y)
(eq-fn x y))))
(def vec== (partial coll-eq ==))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment