I have a big list of the form


and would like to assign 0 to each of them, but


doesn't work. While it does work for lists that aren't indexed the way I have them... I tried doing a Do loop but with the size of the list it's extremely slow.


1 Answer 1


You could use

Evaluate[list] = ConstantArray[0, Length[list]]


MapThread[Set, {list, ConstantArray[0, Length[list]]}]

to Set each indexed variable inside of list to 0.

If the indexes for the variables inside list follow a known condition, one can use for example

p[i_ /; i < 3, j_ /; j < 5] = 0

or memorization

p[i_ /; i < 3, j_ /; j < 5] := p[i, j] = 0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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