Allow zero coordinates in cells (d'oh!)
This commit is contained in:
parent
a44e9548a2
commit
29d9c2e549
|
@ -38,19 +38,20 @@
|
||||||
(defn cell?
|
(defn cell?
|
||||||
"Return `true` if `obj` is a cell, as understood by MicroWorld, else `false`."
|
"Return `true` if `obj` is a cell, as understood by MicroWorld, else `false`."
|
||||||
[obj]
|
[obj]
|
||||||
(and (map? obj) ;; it's a map...
|
(let [x (:x obj)
|
||||||
|
y (:y obj)]
|
||||||
|
(and (map? obj) ;; it's a map...
|
||||||
;; TODO: it's worth checking (and this does not) that cells have the
|
;; TODO: it's worth checking (and this does not) that cells have the
|
||||||
;; right co-ordinates!
|
;; right co-ordinates!
|
||||||
(pos-int? (:x obj)) ;; with an x co-ordinate...
|
(or (zero? x)(pos-int? x)) ;; with an x co-ordinate...
|
||||||
(pos-int? (:y obj)) ;; and a y co-ordinate...
|
(or (zero? y)(pos-int? y)) ;; and a y co-ordinate...
|
||||||
(keyword? (:state obj)))) ;; and a state which is a keyword.
|
(keyword? (:state obj))))) ;; and a state which is a keyword.
|
||||||
|
|
||||||
(defn world?
|
(defn world?
|
||||||
"Return `true` if `obj` is a world, as understood by MicroWorld, else `false`."
|
"Return `true` if `obj` is a world, as understood by MicroWorld, else `false`."
|
||||||
[obj]
|
[obj]
|
||||||
(and (coll? obj) ;; it's a collection...
|
(and (coll? obj) ;; it's a collection...
|
||||||
(every? coll? obj) ;; of collections...
|
(every? coll? obj) ;; of collections...
|
||||||
(= 1 (count (set (map count obj)))) ;; all of which are the same length...
|
|
||||||
(every? cell? (flatten obj)))) ;; and every element of each of those is a cell.
|
(every? cell? (flatten obj)))) ;; and every element of each of those is a cell.
|
||||||
|
|
||||||
(defmacro make-cell
|
(defmacro make-cell
|
||||||
|
|
Loading…
Reference in a new issue