Suppose I have the code:
#!/usr/local/bin/MathematicaScript -script
SetOptions[$Output, FormatType -> OutputForm];
foo[bar_?IntegerQ, baz_?IntegerQ] = bar;
M[g_?IntegerQ] = Module[
{sum},
sum = Sum[foo[i, g], {i, 1, 4} ];
N[sum]
];
Print[M[1]]
Why does this output:
foo[1., 1] + foo[2., 1] + foo[3., 1] + foo[4., 1]
When simply changing the g to a 1 as following correctly interprets the iterator as an integer?
#!/usr/local/bin/MathematicaScript -script
SetOptions[$Output, FormatType -> OutputForm];
foo[bar_?IntegerQ, baz_?IntegerQ] = bar;
M[g_?IntegerQ] = Module[
{sum},
sum = Sum[foo[i, 1], {i, 1, 4} ];
N[sum]
];
Print[M[1]]
This outputs (as expected):
10

N[sum]part is in it. I don't know how I overlooked theSetDelayedoption; I've been looking at it for too long... Thanks! – highphi Sep 8 '12 at 14:45