Last active
August 29, 2015 14:07
-
-
Save squeedee/bfad8db75f4664e4ad75 to your computer and use it in GitHub Desktop.
This file contains 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 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)) |
This file contains 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 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