Add find-first as a convenience

This commit is contained in:
oakes
2014-08-01 18:02:20 -04:00
parent 7c07912fda
commit d6174afc1c

View File

@@ -1,5 +1,13 @@
(in-ns 'play-clj.core)
(defn find-first
"Finds the first entity in `entities` for which `match-fn` returns true.
(find-first :player? entities)
(find-first #(= :menu (:id %)) entities)"
[match-fn entities]
(some #(if (match-fn %) %) entities))
(defmacro on-gl
"Runs the macro body on the GL thread.