Jensen's Device: Difference between revisions

added perl
(→‎{{header|Python}}: add comment)
(added perl)
Line 193:
Printf.printf "%f\n" (sum' i 1 100 (fun () -> 1. /. float !i))</ocaml>
Output: 5.187378
 
=={{header|Perl}}==
<perl>my $i;
sub sum {
my ($i, $lo, $hi, $term) = @_;
my $temp = 0;
for ($$i = $lo; $$i <= $hi; $$i++) {
$temp += $term->();
}
return $temp;
}
 
print sum(\$i, 1, 100, sub { 1 / $i }), "\n";</perl>
Output: 5.18737751763962
 
=={{header|Python}}==
Anonymous user