I want to program a code in MATHEMATICA in order to calculate some values in different iteration. For example, assume this list:
list={1,2,3,4,5}
Now assume that the function is :
f1=Function[u,3+u][x]
I want to use a Do
loop to orderly put each integer from the list
into f1
function and Do
loop uses 5 iteration ({i,1,5}
) and gives 5 answers using the values in the list.
For this example, The results will be :
4
5
6
7
8
I wonder if anyone could help me with this problem.
Do[f1[list[[x]]],{x,5}]
and that you got nothing as output. Try telling it toPrint
the output by wrapping thef1[list[[x]]]
with Print[]. The answer that Christopher Cole provided usingMap
is clearly a better way to solve this. $\endgroup$ – Andy Mobley Mar 30 '14 at 15:46