Jensen's Device: Difference between revisions

Added Dart
(Added Asymptote)
(Added Dart)
 
Line 740:
}</syntaxhighlight>
{{out}}
<pre>5.18738</pre>
 
5.18738</pre>
=={{header|Dart}}==
{{trans|C++}}
<syntaxhighlight lang="dart">double i = 0;
double sum(int lo, int hi, double Function() term) {
double temp = 0;
for (i = lo.toDouble(); i <= hi; i++) temp += term();
return temp;
}
 
double termFunc() {
return 1.0 / i;
}
 
void main() {
print(sum(1, 100, termFunc));
}</syntaxhighlight>
{{out}}
<pre>5.187377517639621</pre>
 
=={{header|Delphi}}==
2,127

edits