Skip to content

Instantly share code, notes, and snippets.

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