Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this code to find all the permutations of a set of letters that form legal words.

Module[{str = "abc", chars, len, r, check},
 chars = Characters[str];
 len = StringLength[str];
 r = Range[len];
 check[n_Integer] := 
    StringJoin[chars[[UnrankPermutation[n, r]]]]}, 1];
 DistributeDefinitions[check, chars, r];
 ParallelTable[check[i], {i, 1, len!}]]

I've verified that, if I replace ParallelTable with Table, I get this:

{{}, {}, {}, {"cab"}, {}, {}}

With ParallelTable, however, in addition to that result, I also get warnings like these:

Part::pspec: Part specification Combinatorica`UnrankPermutation[1,{1,2,3}] is neither a machine-sized integer nor a list of machine-sized integers.

Part::pspec: Part specification Combinatorica`UnrankPermutation[2,{1,2,3}] is neither a machine-sized integer nor a list of machine-sized integers.

StringJoin::string: String expected at position 1 in StringJoin[{a,b,c}[[Combinatorica`UnrankPermutation[1,{1,2,3}]]]].

StringJoin::string: String expected at position 1 in StringJoin[{a,b,c}[[Combinatorica`UnrankPermutation[2,{1,2,3}]]]].

These warnings seem to come from kernel 7 and higher. My guess is that the computation reaches those kernels and there isn't any data left, since there are only 6 permutations, and causes them to spit out those warnings.

Is my understanding correct? How do I prevent these warnings?

share|improve this question
I think >> should be <<. – Michael E2 Mar 14 '13 at 14:28
Thanks, changed >> to <<. – Ashley Mar 14 '13 at 15:40
up vote 2 down vote accepted

Add UnrankPermutation to DistributeDefinitions:

DistributeDefinitions[check, chars, r, UnrankPermutation];
share|improve this answer
Is this because UnrankPermutation comes from the Combinatorica package and isn't a built-in? – Ashley Mar 14 '13 at 15:41
Yes. Using Get (<<) loads the definitions in the Combinatorica package. Any you want to use in parallel should have their definitions distributed. – Michael E2 Mar 14 '13 at 15:53
Better use ParallelNeeds["Combinatorica`"]. – Oleksandr R. Mar 14 '13 at 20:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.