Re: Opinion on take-while for stateful transducers

2015-05-12 Thread Andy-
Thanks for the reply. I do like this. I think it's actually more elegant. Definitely going into my toolbox. One thing I dislike is that I still have to re-implement the logic of the already existing (performant & tested) transducers. Also, I could also add a 4th parameter: 'terminate-early?' but

Re: Opinion on take-while for stateful transducers

2015-05-11 Thread Steve Miner
Not an expert, but I’ll throw out an alternative approach that might work for you. I think it’s simpler to use a transducer that calls functions rather than trying to transform an existing transducer to do the cutoff. (defn take-while-accumulating [accf init pred2] (fn [rf] (let [vstate

Opinion on take-while for stateful transducers

2015-05-09 Thread Andy-
Hi *, I first needed a transducer that stopped when the first non-distinct item is seen. Thus changing distinct slightly to: (defn take-while-distinct "Just like clojure.core/distinct but terminating as soon as one duplicate element is seen." [] (fn [rf] (let [seen (volatile! #{})]