comparison org/util.org @ 26:bbffa41a12a9

moved apply-map to util.org from world.org, fixed some grammar problems, made examples more concise
author Robert McIntyre <rlm@mit.edu>
date Mon, 24 Oct 2011 05:41:50 -0700
parents 775d97247dd0
children 122f12f81dc1
comparison
equal deleted inserted replaced
25:775d97247dd0 26:bbffa41a12a9
215 (.attachChild node element)) 215 (.attachChild node element))
216 ([game element] 216 ([game element]
217 (add-element game element (.getRootNode game)))) 217 (add-element game element (.getRootNode game))))
218 218
219 219
220 (defn apply-map
221 "Like apply, but works for maps and functions that expect an
222 implicit map and nothing else as in (fn [& {}]).
223 ------- Example -------
224 (defn demo [& {:keys [www] :or {www \"oh yeah\"} :as env}]
225 (println www))
226 (apply-map demo {:www \"hello!\"})
227 -->\"hello\""
228 [fn m]
229 (apply fn (reduce #(into %1 %2) [] m)))
220 230
221 #+end_src 231 #+end_src
222 232
223 233
224 234