This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-29
Channels
- # announcements (4)
- # architecture (1)
- # beginners (113)
- # boot (17)
- # calva (40)
- # cider (9)
- # clara (1)
- # cljs-dev (21)
- # cljsrn (21)
- # clojure (47)
- # clojure-dev (8)
- # clojure-europe (2)
- # clojure-italy (46)
- # clojure-nl (10)
- # clojure-spec (1)
- # clojure-turkiye (1)
- # clojure-uk (46)
- # clojurescript (102)
- # core-async (21)
- # cursive (35)
- # data-science (1)
- # datomic (7)
- # emacs (2)
- # graphql (1)
- # lumo (15)
- # nrepl (4)
- # nyc (1)
- # off-topic (5)
- # overtone (3)
- # pathom (10)
- # quil (6)
- # re-frame (30)
- # reagent (7)
- # reitit (33)
- # rewrite-clj (1)
- # shadow-cljs (37)
- # spacemacs (73)
- # test-check (3)
- # testing (2)
- # vim (59)
Is that possible to enclose >! <! into a function, and use that function inside a go block?
most likely not, because function is a black box for state machine compiler, can somebody confirm?
no, it's not possible
for that reason
the parking calls need to be in the lexical scope of the go
go block returns a channel, is that channel closed already? How to make multiple go blocks work with merge.
at the end i want to group result of multiple concurrent tasks into a vector, so i was thinking of into
merge
few go
's
The go block returns a channel that will emit the value returned by the body and then close, afaik
To do that, have a look at core.async/map, it applies f to the values read from the channels passed, to get a vector
applies the function vector to all the values read, 1 value per channel, and puts into a vector
yeah will do, surprised that go
doesn't close channel after value was put into it
(<!! (async/map vector [(async/go 1)
(async/go 2)
(async/go 3)]))
By merge you will have a channel that combines all the values from the others, so you will read one by one the results of the tasks as they come in
looks like in case of multiple go's merge will work aswell, it wasn't working at first, i was thinking go channels wasn't closed until you take a value
(<!! (async/map vector
[(async/go 1)
(async/go 2)
(async/go 3)]))
=> [1 2 3]
(<!! (async/into [] (async/merge [(async/go 1)
(async/go 2)
(async/go 3)])))
=> [1 2 3]