I tried combining tobyink's OOP and your solution ;-)
use v5.16; package Local::App2 { use Exporter::Shiny 'S'; use PDL; sub a { my $n = shift; my $pdl = sequence($n) + 1; my $ans = 1 + (1/$pdl); } sub S { my $n = shift; my $s = a($n)->sumover; } } use Local::App2 'S'; say S(15);
Output
18.318228993229
In reply to Re^2: Solving a maths problem with Perl
by marioroy
in thread Solving a maths problem with Perl
by tobyink
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |