Skip to content

Instantly share code, notes, and snippets.

Created Feb 23, 2015
What would you like to do?
peek into transducing
(ns transpeek.core
(:import (java.util ArrayList)))
(defn map-
(fn [rf]
([] (rf))
([result] (rf result))
([result input]
(rf result (f input)))
([result input & inputs]
(rf result (apply f input inputs)))))))
(defn peek-xform [xform]
(let [list (ArrayList.)]
[(fn [rf]
(let [rf- (xform rf)]
([] (rf-))
([result] (rf- result))
([result input]
(let [res (rf- result input)]
(.add list res)
([result input & inputs]
(rf- result inputs)))))
(def xform (map- inc))
#_(let [value (peek-xform xform)]
(into [] (first value) [0 1 2 3 4])
(clojure.pprint/pprint (last value)))
(let [value (peek-xform xform)]
(transduce (first value) conj [0 1 2 3 4])
(clojure.pprint/pprint (last value)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment