I have this code:
elList = {"H", "C", "N", "O", "F", "Cl"};
els = {"Ca", "O", "C", "Si", "H"};
corr = ConstantArray[1.0, Length@els];
For[i = 1, i <= Length@els, i++,
If[!MemberQ[elList, els[[i]]], corr[[i]] = 1.13];
]
What would be the best way to replace the loop, in other words, how to replace it in the Mathematica way?
My only idea was:
(MemberQ[elList, #] & /@ els) /. {True -> 1.0, False -> 1.13}
Is there a better way or other way?