Hello fellow Clojurians,

I have just released the first version of clj-conduit 
<https://github.com/hyPiRion/clj-conduit> – a small library that attempts 
to make transducers a bit more readable.

To give you a taste, here's the take transducer implemented with 
clj-conduit:

(ns my.namespace
 (:refer-clojure :exclude [await])
 (:require [com.hypirion.conduit :refer [await yield conduit]]))

(defn taking [n]
  (conduit
    (dotimes [_ n]
      (yield (await)))))


Compare this with how take is implemented in clojure.core:

(defn take
  ([n]
     (fn [rf]
       (let [nv (volatile! n)]
         (fn
           ([] (rf))
           ([result] (rf result))
           ([result input]
              (let [n @nv
                    nn (vswap! nv dec)
                    result (if (pos? n)
                             (rf result input)
                             result)]
                (if (not (pos? nn))
                  (ensure-reduced result)
                  result)))))))
   ...)


Information about usage and source code can be found over at 
https://github.com/hyPiRion/clj-conduit

https://github.com/hyPiRion/clj-conduit/wiki/clojure.core-ports contains 
all the clojure.core transducers implemented with conduit, to give you some 
examples to look at.

I also wrote a blogpost about it, explaining usage, implementation details 
and the 
rationale: http://hypirion.com/musings/transducers-to-conduits-and-back

-- Jean Niklas

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to