Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
(ns rollup.core
(:require [clojure.core.async :refer [go chan <! put! timeout alt! alts!]]))
(def ch (chan))
(loop [stash []]
(let [[v c] (alts! [ch (timeout 3000)])]
(if (= c ch)
(when v
(when (< (count stash) 5)
(println "A" v))
(recur (conj stash v)))
(when (not-empty stash)
(println "B" stash))
(recur []))))))
(dotimes [n 20] (put! ch n))
(clojure.core.async/close! ch)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment