Skip to content

Instantly share code, notes, and snippets.

@darkone23
Last active December 28, 2015 04:49
Show Gist options
  • Save darkone23/7445491 to your computer and use it in GitHub Desktop.
Save darkone23/7445491 to your computer and use it in GitHub Desktop.
huh?
; egghead@thoth: ~/projects/clojure/async
; ~> time lein run
; => lein run 7.29s user 0.60s system 114% cpu 6.888 total
; egghead@thoth: ~/projects/clojure/async
; ~> cat output.txt | wc -l
; => 97
; egghead@thoth: ~/projects/clojure/async
; ~> cat src/async/core.clj
(ns async.core
(:require [clojure.core.async :refer (chan go-loop <! >!!)])
(:gen-class))
(defn -main
"I don't do a whole lot ... yet."
[& args]
(let [output (chan 10)]
(go-loop [message (<! output)]
(spit "output.txt" (str "I got a message: " message "\n") :append true)
(recur (<! output)))
(doseq [x (range 100)]
(>!! output x))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment