Basically, the title says it all. I am familiar with python, not so much with mathematica. For the program, I am starting out with three unique lists of values for which I am using a triple nested For loop to extract each term. Then, I am multiplying these extracted terms together and appending them to a new blank list. Since I feel I may not be explaining my intentions that well, my basic goal is to go from:
listA = {1, 2, 3}
listB = {4, 5, 6}
listC = {7, 8}
listFinal = {}
to then appending listFinal in a manner to obtain:
listFinal = {1*4*7, 1*4*8, 1*5*7, 1*5*8, 1*6*7, 1*6*8, 2*4*7, 2*4*8, etc...}
When I would create this loop in python, I would start with a blank list (listFinal), that I would then append these multiplied values to after indexing each value at the end of a triple nested For loop.
However, when I attempt to create this program in mathematica, I am left with a non-appended (blank) listFinal. Do you all know of a way to fix my nested For loop so it would function as intended, or use a different method of achieving my desired results? I've been searching through forums and have been met with the consensus that for loops are not the most efficient/best method of programming in mathematica. However, I am most familiar with using them, which is why my attempts so far have been with only for loops.
My original program is as follows:
m = List[.9, .8, .7, .8, .7, .6]
g = List[1, .95, .9, .95, .85, .75]
b = List[.85, .75, .65]
effectiveFlux = List[];
For[i = 1, i < 7, i++,
For[j = 1, j < 7, j++,
For[k = 1, k < 4, k++,
var = m[[{i}]]*g[[{j}]]*b[[{k}]]
Append[effectiveFlux, var]]]]
Thank you in advance!
AppendTo [ ]
... but that isn't good Mathematica coding style $\endgroup$Outer[]
? $\endgroup$var
assignment $\endgroup$