Allow zero coordinates in cells (d'oh!)
This commit is contained in:
parent
a44e9548a2
commit
29d9c2e549
|
@ -38,19 +38,20 @@
|
|||
(defn cell?
|
||||
"Return `true` if `obj` is a cell, as understood by MicroWorld, else `false`."
|
||||
[obj]
|
||||
(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
|
||||
;; right co-ordinates!
|
||||
(pos-int? (:x obj)) ;; with an x co-ordinate...
|
||||
(pos-int? (:y obj)) ;; and a y co-ordinate...
|
||||
(keyword? (:state obj)))) ;; and a state which is a keyword.
|
||||
(or (zero? x)(pos-int? x)) ;; with an x co-ordinate...
|
||||
(or (zero? y)(pos-int? y)) ;; and a y co-ordinate...
|
||||
(keyword? (:state obj))))) ;; and a state which is a keyword.
|
||||
|
||||
(defn world?
|
||||
"Return `true` if `obj` is a world, as understood by MicroWorld, else `false`."
|
||||
[obj]
|
||||
(and (coll? obj) ;; it's a collection...
|
||||
(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.
|
||||
|
||||
(defmacro make-cell
|
||||
|
|
Loading…
Reference in a new issue