title: How do I map over a list of async channels in the order they exist in a list?
body: <p>I'm having trouble returning the values from core.async channels in the browser in the order they were created (as opposed to the order at which they return a value). The channels themselves are returned from mapping cljs-http.client/get over a list of URLs. </p>
  
  <p>If I bind the results manually in a <code>let</code> block then I can return the results in the order of the channels "by hand", but this obviously a problem when I don't know how many channels exist.</p>
  
  <pre class="lang-clj prettyprint-override"><code>(let [response-channels (map #(http/get "http://date.jsontest.com" {:with-credentials? false}) (range 3))]
  
    ; Response is now three channels generated by http/get:
  
    ;(#object[cljs.core.async.impl.channels.ManyToManyChannel]
    ; #object[cljs.core.async.impl.channels.ManyToManyChannel]
    ; #object[cljs.core.async.impl.channels.ManyToManyChannel])
  
    ; If I want the results back in the guaranteed order that I made them, I can do this:
    (go (let [response1 (&lt;! (nth response-channels 0))
              response2 (&lt;! (nth response-channels 1))
              response3 (&lt;! (nth response-channels 2))]
          (println "This works as expected:" response1 response2 response3))))
  </code></pre>
  
  <p>But if I try to map <code>&lt;!</code> over the channels instead of binding to them individually then I just get a the list of channels instead of their values.</p>
  
  <pre class="lang-clj prettyprint-override"><code>(let [response-channels (map #(http/get "http://date.jsontest.com" {:with-credentials? false}) (range 3))]
  
  
    (let [responses (into [] (map (fn [c] (go (&lt;! c))) response-channels))]
      (println "This just returns the channels:" responses)
  
      ; This is still just a vec of many-to-many channels
      ; [#object[cljs.core.async.impl.channels.ManyToManyChannel]
      ; #object[cljs.core.async.impl.channels.ManyToManyChannel]
      ; #object[cljs.core.async.impl.channels.ManyToManyChannel]]
      )
    )
  </code></pre>
  
  <p>I suspect it's a problem with the location of the <code>go</code> block, however I can't move it outside of the anonymous function without an error that I'm using <code>&lt;!</code> outside of a <code>go</code> block.</p>
  
  <p>This doesn't work:</p>
  
  <pre class="lang-clj prettyprint-override"><code>(into [] (go (map &lt;! response-channels)))
  </code></pre>
  
  <p>And neither does this:</p>
  
  <pre class="lang-clj prettyprint-override"><code>(go (let [responses (into [] (map &lt;! response-channels))]))
  </code></pre>
  
  <p>I also tried merging the channels via <code>async/merge</code> and then using <code>async/reduce</code> to conjoin the values but results are in the order of when the requests were fulfilled, not the order of the channels being merged.</p>
  
  <p>Can anyone shed some light on retrieving values from a list of channels in the order the channels exist in the list?</p>