Perfect! And Thanks!
Tim
On Jun 22, 7:00 pm, Michał Marczyk <michal.marc...@gmail.com> wrote:
> Firstly, consider using Delays rather than IFn. See (doc delay) and
> (doc delay?). In Clojure, many sorts of things are IFns, including
> (among others) sets, vectors and maps, and you probably don't want to
> call those.
>
> (def uhoh* (ref {:event {:date (delay (java.util.Date.)) :name "EOW"}}))
> (def why* (ref {:event {:stuff "ELI"}}))
>
> Then you could do something like
>
> (def current*
>            (zipmap (mapcat keys [(uhoh* :event) (why* :event)])
>                    (mapcat #(->> % vals
>                                  (map (fn [item] (if (delay? item)
> @item item))))
>                            [(uhoh* :event) (why* :event)])))
>
> If you really want to use IFns and not Delays, change (delay? item) to
> (ifn? item) and @item to (item).
>
> For more general tree walking, see clojure.walk. E.g.
>
> (def current*
>      (walk/prewalk #(if (delay? %) @% %)
>                    (merge (uhoh* :event)
>                           (why* :event))))
>
> will give you the same thing.
>
> Sincerely,
> Michał

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to