summary history branches tags files
commit:e8c2ed52cc6ae1b95f310892349868bcc606bf14
author:mrmekon
committer:mrmekon
date:Mon Apr 2 22:34:55 2012 -0400
parents:6e78384bb1aca29e9e7550e4b5e69d8a8fa97f8b
Replaced unnecessary recursing functions with map.
diff --git a/tempest/tempest/core.cljs b/tempest/tempest/core.cljs
line changes: +3/-20
index 6ca20eb..c255811
--- a/tempest/tempest/core.cljs
+++ b/tempest/tempest/core.cljs
@@ -216,20 +216,10 @@ flipper appears to flip 'inside' the level:
      (not (nil? permanent-dir)) (swap-flipper-permanent-dir flipper)
      :else flipper)))
 
-(defn consider-flipping
-  [entity-list]
-  ((fn [oldlist newlist]
-     (let [entity (first oldlist)]
-       (if (empty? entity)
-         newlist
-         (recur (rest oldlist)
-                (cons (maybe-engage-flipping entity) newlist))))
-         ) entity-list []))
-
 (defn update-entity-is-flipping
   [game-state]
   (let [{enemy-list :enemy-list} game-state]
-    (assoc game-state :enemy-list (consider-flipping enemy-list))))
+    (assoc game-state :enemy-list (map maybe-engage-flipping enemy-list))))
 
 (defn update-entity-flippyness
   [game-state]
@@ -302,16 +292,9 @@ flipper appears to flip 'inside' the level:
                   (build-projectile level 0 5 :step 100))))))
   
 (defn update-entity-list
-  "Recursively call update-entity-position! on all entities in list."
+  "Call update-entity-position! on all entities in list."
   [entity-list]
-  ((fn [oldlist newlist]
-     (let [entity (first oldlist)]
-       (if (empty? entity)
-         newlist
-         (recur (rest oldlist)
-                (cons (update-entity-position! entity) newlist))))
-         ) entity-list []))
-
+  (map update-entity-position! entity-list))
 
 (defn entity-between-steps
   "Returns true of entity is on seg-idx, and between steps step0 and step1,