This seems like something simple but I can't find the answer.
If I have as input:
{{1, 2}, {3, d}} /. d -> {4, -4}
Mathematica outputs:
{{1, 2}, {3, {4, -4}}}
(which is logical as it simply replaces d
with the list given)
What I'd like is the following output, i.e., a new list of complete 2x2 matrices:
{{{1, 2}, {3, 4}}, {{1, 2}, {3, -4}}}
To give a bit more context, I have two lists of matrices that I'd like to multiply to give all the combinations, e.g.:
list1 = {A,B,C}
list2 = {D,E}
into
{A.D,A.E,B.D,B.E,C.D,C.E}
I already found this trick:
Dot @@@ Tuples[{list1, list2}]
But prior to multiplying the list I need to do a replace all as described above to produce the actual matrices to multiply together.
Thanks