This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-05-31
Channels
- # admin-announcements (4)
- # alda (3)
- # aws (1)
- # beginners (2)
- # boot (33)
- # braid-chat (4)
- # braveandtrue (20)
- # cider (52)
- # cljs-dev (13)
- # cljsrn (55)
- # clojure (111)
- # clojure-belgium (4)
- # clojure-brasil (6)
- # clojure-dusseldorf (1)
- # clojure-greece (116)
- # clojure-mexico (1)
- # clojure-nl (3)
- # clojure-russia (56)
- # clojure-spec (72)
- # clojure-uk (13)
- # clojurescript (66)
- # community-development (2)
- # component (24)
- # core-async (1)
- # cursive (19)
- # datomic (27)
- # devcards (5)
- # emacs (1)
- # funcool (34)
- # hoplon (313)
- # jobs (1)
- # lein-figwheel (11)
- # luminus (5)
- # mount (30)
- # off-topic (63)
- # om (375)
- # onyx (67)
- # perun (8)
- # proton (1)
- # reagent (4)
- # rum (1)
- # specter (55)
- # spirituality-ethics (7)
- # test-check (2)
- # untangled (34)
- # yada (20)
Hello all, Why this don´t work?
(defn inicia []
(for [id (range 10)]
(println "ID => " id)))
(defstate shaper
:start (inicia) )
i.e.
dev=> (defn inicia [] (for [id (range 10)] (println "ID => " id)))
#'dev/inicia
dev=> (defstate shaper :start (inicia))
">> starting.. #'dev/shaper (namespace was recompiled)"
#'dev/shaper
dev=> shaper
ID => 0
ID => 1
ID => 2
ID => 3
ID => 4
ID => 5
ID => 6
ID => 7
ID => 8
ID => 9
(nil nil nil nil nil nil nil nil nil nil)
in case you just want a range
:
dev=> (defstate foo :start (range 10))
#'dev/foo
dev=> (mount/start #'dev/foo)
{:started ["#'dev/foo"]}
dev=> foo
(0 1 2 3 4 5 6 7 8 9)
I tried with overtone.at-at that creates a schedule object, but I had to call shaper in repl to processes starting up
I read the config from file that define devices to monitoring, from config file that returns a list of devices, on each I want to start a schedule with overtone.at-at
(for [device (:device config)]
(let
[nome-device (name (key device))
conf-device ((key device) (:device config))
cadencia (Integer. (:cadencia (:shaper conf-device)))]
(log/debug (str "Iniciando processo Traffic Shaper para " nome-device))
(at/every (* cadencia 1000) #(processo-shaper nome-device conf-device storage) pool :desc nome-device :fixed-delay true)))
right, so for
is lazy, if you'd like them to be scheduled when this expression is called, use doseq
dev=> (defn inicia []
(doall (for [id (range 10)]
(let [foo 42]
(println "ID => " id)
(+ id foo)))))
#'dev/inicia
dev=> (defstate fooz :start (inicia))
#'dev/fooz
dev=> (mount/start #'dev/fooz)
ID => 0
ID => 1
ID => 2
ID => 3
ID => 4
ID => 5
ID => 6
ID => 7
ID => 8
ID => 9
{:started ["#'dev/fooz"]}
dev=> fooz
(42 43 44 45 46 47 48 49 50 51)
the problem was I didn´t know that lazy seqs don´t work with mount start, thanks a lot 4 ur help