PS: I just realized that the code, as I wrote it, will not work, as nesting of # is forbidden.

My actual code is:

(defn is-element-in-list [e l]
  (some #{e} l))

(filter #(is-element-in-list % small-list) big-list)

Sorry about that.

Deyan


On 12/12/2017 02:24 PM, Deyan Yotsov wrote:
Hello,

I have one list of potentially up to 2 million strings: big-list.

Then I have another list, small-list, the elements of which are a subset of the elements of big-list.

I want to sort the elements in small-list so that they become sorted in the same way in which they are sorted in big-list.

The most obvious way to do this, for me, is:

(filter #(some #{%} small-list) big-list)

(one by one we take the elements from big-list, we check if they are in small-list, and if they are, we add them (in big-list order) to the result)

But of course this performs extremely poorly, especially if small-list is say 1M elements, and big-list is 2M elements.

Suggestions?

Thank you,

Deyan


--
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
--- You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to