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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

One post - replies to several good brethren and sisthren.

>Re: Not very Perlish? (note the capital P ;) - Noted!

>If it works, it's Perl. - True - but I wish to extend my knowledge

> you're throwing down the gauntlet for Perl Golf. - Que? "Perl Golf"?

my @items = map {$_ % 100 } @_; my $sum = 100; $sum -= $_ for @items[0..2]; $items[ $sum<0?0:2 ] += $sum unless $sum == 0;

Neat! i *think* I understand this.

Brother Frankus. - Thankyou.


Here's a Perl program that takes N numbers and scales them such that their sum becomes 100, but their ratios remain the same.

- Probably what I was unconciously seeking.

Abigail - Thankyou. This is what I will be using!


~Particle *accelerates* - I need to sanitise all inputs and continue to run. - probably an easy mod IF I understood how yours worked :)


Not sure why we're doing a modulo 100 operation here unless it's a substitution for the int() operator.

Seemed like the easy way to
a) force values <100
b) deal with non-integer inputs?

--t. alex - Thankyou.


> I think you have an excellent start - Is this "faint praise" ? :)

>. You can simplify it a fair bit, however: - And in a couple of (now you pointed them out!) very obvious ways.

- tye (but my friends call me "Tye") - Thanyou! (May I call you Tye?:)


When is P the compliment of ch?
When they are in the company of Erlish!


In reply to Re: Not very perlish? by Anonymous Monk
in thread Not very perlish? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found