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 set of unique tokens. It works and is just as fast as a messier loop/recur version. (defn take-as-many-as-possible-until [ss tok-fn m] (let [items (atom #{})] (-> (fn [v] (swap! items (partial apply merge) (tok-fn v)) (< (count @items) m)) (take-while ss)))) However, I have noticed that the take-while documentation says that the pred function should be side-effect free. Will this be problem in my implementation if I am calling it from multiple threads? And what would be the more idiomatic way of implementing this kind of behaviour? Thanks, Shaobo -- 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