Jensen's Device: Difference between revisions

Content added Content deleted
(Add Seed7 example)
Line 169:
}
}</lang>
=={{header|Clipper}}==
With hindsight Algol60 provided this feature in a way that is terrible for program maintenance, because the calling code looks innocuous.
<lang Clipper>// Jensen's device in Clipper (or Harbour)
// A fairly direct translation of the Algol 60
// John M Skelton 11-Feb-2012
 
function main()
local i
? transform(sum(@i, 1, 100, {|| 1 / i}), "##.###############")
// @ is the quite rarely used pass by ref, {|| ...} is a
// code block (an anonymous function, here without arguments)
// The @i makes it clear that something unusual is occurring;
// a called function which modifies a parameter is commonly
// poor design!
return 0
 
function sum(i, lo, hi, bFunc)
local temp := 0
for i = lo to hi
temp += eval(bFunc)
next i
return temp
</lang>
 
=={{header|Common Lisp}}==