(with-query ;; query all collidable entities (binding to ?entity-a) (and (collidable . ?entity-a) ;; bind all nearby collidable entities to ?entity-b ;; discarding any pairs where ?entity-a is equal to ?entity-b (collidable . ?entity-b) (not (same? ?entity-a ?entity-b)) (is-nearby? ?entity-a ?entity-b) ;; and discarding pairs that aren't colliding (colliding? ?entity-a ?entity-b)) (format t "entities ~s and ~s are colliding! ~%" (name ?entity-a) (name ?entity-b)))) entities "test" and "test3" are colliding! entities "test2" and "test" are colliding! entities "test2" and "test3" are colliding! entities "test3" and "test" are colliding! entities "test3" and "test2" are colliding!