Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This works as expected:

Table[x[1], {x[1], 1, 10}]

However, the parallel version

ParallelTable[x[1], {x[1], 1, 10}]

complains that the expression cannot be parallelized. (The same applies to other iterators like Subscript[x,1] etc. instead of x[1].) How can I fix that?

share|improve this question

2 Answers 2

This works as well, similar to Sjoerd C. de Vries' method:

Block[{x}, x[1] = Unique[]; ParallelTable[x[1], {x[1], 1, 10}]]

{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

And this does, too:

Block[{x}, x /: Subscript[x, i] = Unique[]; 
 ParallelTable[Subscript[x, i], {Subscript[x, i], 1, 10}]]

{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

share|improve this answer

This works, but looks rather clumsy to me:

Hold[ParallelTable[x[1], {x[1], 1, 10}]] /.  x[i_] -> Unique[] // ReleaseHold

{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

Also works for subscripts:

Hold[ParallelTable[Subscript[x, i], {Subscript[x, i], 1, 10}]] /. 
     Subscript[x, i_] -> Unique[] // ReleaseHold

{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

share|improve this answer

Your Answer

 
discard

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.