Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Solving a maths problem with Perl

by marioroy (Prior)
on Aug 10, 2024 at 07:54 UTC ( [id://11160976]=note: print w/replies, xml ) Need Help??


in reply to Re: Solving a maths problem with Perl
in thread Solving a maths problem with Perl

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11160976]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2025-02-09 15:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (96 votes). Check out past polls.