SHARE
TWEET

Untitled

a guest Dec 7th, 2019 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (ns rivershy
  2.   (:require [clojure.core.async :as a]))
  3.  
  4. (def c1 (a/chan 10))
  5. (def c2 (a/chan 10))
  6. (def cr (a/chan 10))
  7.  
  8. (a/onto-chan c1 ["a" "1" "c" "d" "q"])
  9. (a/onto-chan c2 ["a" "b" "c" "d" "e"])
  10.  
  11. (defn eq-chans [a b r]
  12.   (a/go-loop []
  13.     (let [av (a/<! a)
  14.           bv (a/<! b)]
  15.       (when (= av bv)
  16.         (a/>! r [av bv])
  17.         (recur)
  18.         )
  19.       )
  20.     )
  21.   )
  22.  
  23. (defn consumer []
  24.   (a/take! cr (fn [x] (println (str "received" x)) (consumer name))))
  25.  
  26. (eq-chans c1 c2 cr)
  27.  
  28. (consumer)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top