Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Stupidest Prime Number detector ever!!

by AnomalousMonk (Archbishop)
on Jun 23, 2021 at 20:48 UTC ( [id://11134216]=note: print w/replies, xml ) Need Help??


in reply to Stupidest Prime Number detector ever!!

... I am trying to learn how to create modules and needed something to work on. ... create a module out of [this monstrosity] by doing the required changes, test the output by checking it ...

This seems like a reasonable way to learn about creating modules: start with a lousy algorithm, create a MyModule.pm that exports something like is_prime(), create a MyModule.t for the module to test its correct operation (and which can also test execution time), then start improving the algorithm to exercise the process of developing, improving and maintaining the module.

Ok, you've got the lousy algorithm. So where's the module and its .t script? That seems to me to be the thing to focus on right now. (There are even some who say that one should write the .t script before writing the module!) Believe me, you'll find plenty of ways to improve and extend things once you've got the algorithm encapsulated in a module along with a .t script for it, i.e., once the interface is defined and testable. Interface definition and creation of a testing environment is the first step. Go for it. But at this stage, why are you worrying about better algorithms?


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^2: Stupidest Prime Number detector ever!!
by Anonymous Monk on Jun 23, 2021 at 22:04 UTC

    Hi Anomalous Monk

    ,

    For a moment I was wondering when and why did I reply to myself, but then I noticed the name!!

    I've written a very basic test and updated the original post with it so that it will be there for all to review. Thank you

      Please consider becoming a registered user. This will allow you to edit/update your posts (but you still won't be able to edit any anonymous post, neither your own nor anyone else's). If you're interested in creating an account on PerlMonks, please see Creating an account on PerlMonks. :)

      If you do edit any of your registered-user posts, please review How do I change/delete my post? first.


      Give a man a fish:  <%-{-{-{-<

        Hi Anomalous Monk, truth is I'm a registered user, but I don't have the guts to put up this kind of bad code under my username.

        I'm jobless right now and hoping to get a Perl related job. My username is pretty unique and resolves to my first and last name. Most of the Perl experts hang out here and if they find I've asked these kind of stupid questions, written this kind of bad code and the word gets out, no one would give me a job for sure :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-26 06:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found