我有这个代码来查找形成合法单词的一组字母的所有排列。
>>Combinatorica`
Module[{str = "abc", chars, len, r, check},
chars = Characters[str];
len = StringLength[str];
r = Range[len];
check[n_Integer] :=
DictionaryLookup[{"BritishEnglish",
StringJoin[chars[[UnrankPermutation[n, r]]]]}, 1];
DistributeDefinitions[check, chars, r];
ParallelTable[check[i], {i, 1, len!}]]
我已经验证,如果我用 Table 替换 ParallelTable,我会得到:
{{}, {}, {}, {"cab"}, {}, {}}
但是,使用 ParallelTable,除了该结果之外,我还会收到如下警告:
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}]]]].
这些警告似乎来自内核 7 及更高版本。我的猜测是计算到达那些内核并且没有任何数据留下,因为只有 6 个排列,并导致它们吐出这些警告。
我的理解正确吗?如何防止这些警告?