(map #(do %2 %1) c1 c2) is a neat trick I hadn't seen in this context;
thanks for showing me!
On Sunday, September 2, 2012 10:26:07 PM UTC-7, Stephen Compall wrote:
>
> On Fri, 2012-08-31 at 05:08 -0700, shaobohou wrote:
> > 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
>
> Only because in the current implementation, take-while happens to be
> called in coll order, which is not a guarantee of the API.
>
> > Will this be problem in my implementation if I am calling it from
> > multiple threads?
>
> No.
>
> > And what would be the more idiomatic way of implementing this kind of
> > behaviour?
>
> Consider this restructuring:
>
> (->> 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 suits you.
>
> --
> Stephen Compall
> "^aCollection allSatisfy: [:each | aCondition]": less is better than
>
>
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en