 
 (ns cljs-examples
   (:require [cljs.core.async :refer [chan put! take! timeout] :as async]
+            [clojure.walk :refer [prewalk]]
             [goog.net.XhrIo])
   (:require-macros [cljs.core.async.macros :refer [go]]))
 


(avg [1 2 3 4 5])

(defn get-helper [k col]
  (get col k))

(defn avg-cast-popularity [id]
  (go
   (let [cast (->> (movie-cast id)
                   <!
                   (get-helper "cast")
                   (clojure.core/map (partial get-helper "id"))
                   (clojure.core/map people-by-id)
                   (async/map vector)
                   <!
                   (clojure.core/map (partial get-helper "popularity"))
                   avg)]
     cast)))



(go (println "It works!" (<! (go 42))))

;; Wait....why did we use <!! Well <!! is simply a function that uses
;; blocking promises to wait for channel values. That would mess up the fixed
;; size thread pool that go blocks dispatch in. So we must define two sets
;; of operations
