*Github Link: https://github.com/robertluo/fun-map*
It is a lazy map:
(def m (fun-map {:a 4 :b (delay (println "accessing :b") 10)}))
and can also be a future map:
(def m (fun-map {:a (future (do (Thread/sleep 1000) 10))
:b (future (do (Thread/sleep 1000) 20))}))
or mixed:
(def m (fun-map {:a (future (do (Thread/sleep 1000) 10))
:b (delay 20)}))
or cascading function calls:
(def m (fun-map {:xs (range 10)
:count-keys ^:wrap (fn [m] (count (keys m)))
:sum (fnk [xs] (apply + xs))
:cnt (fnk [xs] (count xs))
:avg (fnk [sum cnt] (/ sum cnt))}))
or even a light weight system can be halted in order:
(def system
(life-cycle-map
{:component/a
(fnk []
(reify java.io.Closeable
(close [_]
(println "halt :a"))))
:component/b
(fnk [:component/a]
(reify java.io.Closeable
(close [_]
(println "halt :b"))))}))
(touch system) ;;start the system
(halt! system)
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.