Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(ns mapper.util.diff
(:require [mapper.util :refer :all]
[mapper.core :refer :all]))
(defn diff [[width height] map-a map-b]
"A utility for testing map equality. Compares map-a and map-b elementwise and returns true if they're the same.
E.g.: diff [2 2] '(:a :b :c :d) '(:a :b :c :z) => '(true true true false)"
(let [map-a-coll (map-as-list [width height] map-a)
map-b-coll (map-as-list [width height] map-b)]
(map = map-a-coll map-b-coll)))
; possibly doesnt belong in this ns
(defn all-true? [coll]
(every? identity coll))
(ns mapper.util.diff
(:require [mapper.util :refer :all]
[mapper.core :refer :all]))
(defn diff [[width height] map-a map-b]
"A utility for testing map equality. Compares map-a and map-b elementwise and returns true if they're the same.
E.g.: diff [2 2] '(:a :b :c :d) '(:a :b :c :z) => '(true true true false)"
(let [map-a-coll (map-as-list [width height] map-a)
map-b-coll (map-as-list [width height] map-b)]
(map = map-a-coll map-b-coll)))
(defn diff? [dimensions map-a map-b]
"A utility for testing map equality. Compares map-a and map-b elementwise and returns true if they're the same.
E.g.: diff [2 2] '(:a :b :c :d) '(:a :b :c :z) => false
diff [2 2] '(:a :b :c :d) '(:a :b :c :d) => true"
(every? true? (diff dimensions map-a map-b)))
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.