Jensen's Device: Difference between revisions

Content deleted Content added
Line 114:
i = Ref()
def sum(ref_i, lo, hi, term):
# term is passed by-name, and so is i #
temp = 0;
for i in range(lo,hi+1):
ref_i.value = i;
temp += term()
return temp
# note the correspondence between the mathematical notation and the call to sum #
print (sum (i, 1, 100, lambda: 1.0/i.value))</python>
Output: 5.18737751764