Created
February 19, 2018 17:09
-
-
Save otfrom/60b9f9fa7c3f345710aa894fca83771c to your computer and use it in GitHub Desktop.
How I learned core.async
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns otfrom.copper | |
(:require [clojure.core.async :as a])) | |
(def tenner (a/chan)) | |
(def mten (a/mult tenner)) | |
(def t1 (a/tap mten (a/chan))) | |
(def t2 (a/tap mten (a/chan))) | |
(def r1 (a/reduce (fn [a n] | |
(println "r1 a: " a " n: " n) | |
(+ a n)) | |
0 | |
t1)) | |
(def r2 (a/reduce (fn [a n] | |
(println "r2 a: " a " n: " n) | |
(* a (inc n))) | |
1 | |
t2)) | |
(a/pipe (a/to-chan (range 10)) tenner) | |
(a/<!! r1) | |
(a/<!! r2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment