(ns home.async-play (:require [clojure.core.async :as async])) (defn long-comp1 [] 5) (defn long-comp2 [] 6) (defn aggregate [xs] (println xs)) ;;simple version, working with 2 functions (let [c1 (async/go (long-comp1)) c2 (async/go (long-comp2))] (async/go (aggregate [(async/<! c1) (async/<! c2)]))) ;;generalized version, working with a sequence of functions (defn fs->chans "Returns channels holding the result of each function execution" [fs] (for [f fs] (async/go (f)))) (let [channels (fs->chans [long-comp1 long-comp2])] (async/go (aggregate (map async/<!! channels))))