I've asked a question here which was resolved by tweaking my code a little. So I shall reiterate, for the following list,
l = {{"a", "b"}, {"a", "b"}, {"c", "d"}, {"e", "f"}, {"e", "f"}, {"x", "y", "z"}, {"m", "n", "o"}, {"p", "q", "s"}}; I want to count each sublist and make a polynomial from them, I do this by:
AssociationThread[ l -> Table[ Total[(x^-Length@l[[i]]) x^ Map[Length, Select[l, ContainsAll[l[[i]]]]]], {i, Length[l]}]] This code does the job correctly yet, the original list I am working with has 38968 sublists and thus the code would take a lot of time to be complied - I wonder how does one optimise this?
I used ParallelTable but for some reason it takes more time!
In[130]:= AssociationThread[ l -> Table[ Total[(x^-Length@l[[i]]) x^ Map[Length, Select[l, ContainsAll[l[[i]]]]]], {i, Length[l]}]] // AbsoluteTiming AssociationThread[ l -> ParallelTable[ Total[(x^-Length@l[[i]]) x^ Map[Length, Select[l, ContainsAll[l[[i]]]]]], {i, Length[l]}]] // AbsoluteTiming Out[130]= {0.000812, <|{"a", "b"} -> 2, {"c", "d"} -> 1, {"e", "f"} -> 2, {"x", "y", "z"} -> 1, {"m", "n", "o"} -> 1, {"p", "q", "s"} -> 1|>} Out[131]= {0.002713, <|{"a", "b"} -> 2, {"c", "d"} -> 1, {"e", "f"} -> 2, {"x", "y", "z"} -> 1, {"m", "n", "o"} -> 1, {"p", "q", "s"} -> 1|>}
Counts[l]? What am I missing? $\endgroup$