This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-15
Channels
- # admin-announcements (10)
- # aws (2)
- # beginners (27)
- # boot (3)
- # cbus (4)
- # cider (1)
- # clara (6)
- # cljs-dev (3)
- # cljsrn (14)
- # clojure (98)
- # clojure-boston (1)
- # clojure-brasil (1)
- # clojure-czech (3)
- # clojure-dusseldorf (11)
- # clojure-greece (3)
- # clojure-japan (3)
- # clojure-korea (1)
- # clojure-russia (138)
- # clojure-uk (11)
- # clojurescript (76)
- # component (2)
- # core-matrix (1)
- # cursive (25)
- # data-science (3)
- # devcards (1)
- # euroclojure (4)
- # events (3)
- # funcool (1)
- # hoplon (219)
- # immutant (40)
- # juxt (8)
- # leiningen (1)
- # off-topic (34)
- # om (148)
- # onyx (10)
- # overtone (2)
- # proton (1)
- # re-frame (8)
- # reagent (3)
- # ring-swagger (5)
- # spacemacs (17)
- # untangled (47)
- # yada (19)
I’m going through the “Clojure for the brave and true book”, and now I’m on the core-async chapter
at the end it gives an example of using channels to create a process pipeline
(def in-chan (chan))
(def upper-caser-out (upper-caser in-chan))
(def reverser-out (reverser upper-caser-out))
(printer reverser-out)
this is nice but my question is, is there a macro or some way to make this more readable?
it just feels to me that this can look more concise
sort of like the ->
macro?
awesome!
yes, they take an in channel
(defn upper-caser
[in]
(let [out (chan)]
(go (while true (>! out (clojure.string/upper-case (<! in)))))
out))
(defn reverser
[in]
(let [out (chan)]
(go (while true (>! out (clojure.string/reverse (<! in)))))
out))
(defn printer
[in]
(go (while true (println (<! in)))))
Does anyone know if there’s a way to do what I’m trying to do here? https://www.refheap.com/117586
Essentially do different work in the macro before actually emitting the output depending on whether it’s generating clojure code or clojurescript code?
@lgastako: thanks for your help!
is your problem the fact that clojure-version is not bound on the client?
does this help? http://stackoverflow.com/questions/4198549/in-clojure-how-can-i-test-if-a-a-symbol-has-been-defined
well, it’s more that even when generating clojurescript code, the macro itself is executing in a clojure environment (the compiler) and so clojure-version is always bound there… if I reference inside the emitted code then it’s bound/not bound accordingly and works great, but in this case I need to be able to filter out some bits incoming args depending on which type of code is being emitted
I was able to get it working using this if-cljs
macro that everyone else seems to use: http://blog.nberger.com.ar/blog/2015/09/18/more-portable-complex-macro-musing