I have a sublist from Tuples[{1, 2, 3}, 2]
, say for example L={{1,2},{2,1},{2,2}}
, and a 3 x 3 matrix M
.
My goal is to create a new list of matrices that has the same length as L
and these matrices are the same as M
except in the position indexed by elements of L
,
that is replaced by some constant number s
.
As I am used to Matlab, I did in an iterative way:
j=1;
While[j <= Length[L],
State = M;
State[[L[[j, 1]], L[[j, 2]]]] = s;
If[MemberQ[NewList, State] == False, AppendTo[NewList, State]];
++j;
];
but it would have be nicer to use the function Map
I guess. So I'm looking for an elegant synthax since a little while.
Thanks.