Re: using take-while with pred function that has state

2012-09-05 Thread shaobohou
On Monday, 3 September 2012 14:03:42 UTC+1, Dave Sann wrote: > > (defn take-while-reduce > "fancy take accumulating a reduced value on taken items > this value can then be tested in the take fn > Much appreciated. -- You received this message because you are subscribed to the Google Grou

Re: using take-while with pred function that has state

2012-09-05 Thread shaobohou
On Monday, 3 September 2012 06:26:07 UTC+1, Stephen Compall wrote: > > (->> ss (map tok-fn), (reductions (partial apply merge) #{}), > (take-while #(...)), (map #(do %2 %1) ss), last) > > Use of `atom' for this sort of thing is certainly an antipattern, so > consider any alternative that su

using take-while with pred function that has state

2012-09-02 Thread shaobohou
Hi, I am trying to write a function which takes a list of strings, tokenize each one, and maximise N such that the number of unique tokens in the first N strings is less than some number M. I have written the following function using take-while and a pred function with an atom to store the se