From d6174afc1c43d2ec69df351fdb5e8be97b8dd8bc Mon Sep 17 00:00:00 2001 From: oakes Date: Fri, 1 Aug 2014 18:02:20 -0400 Subject: [PATCH] Add find-first as a convenience --- src/play_clj/core_utils.clj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/play_clj/core_utils.clj b/src/play_clj/core_utils.clj index d3531d4..5a1ac7c 100644 --- a/src/play_clj/core_utils.clj +++ b/src/play_clj/core_utils.clj @@ -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.