Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: How to convert array key values into percentages

by ww (Archbishop)
on Jan 26, 2014 at 21:01 UTC ( [id://1072149]=note: print w/replies, xml ) Need Help??


in reply to How to convert array key values into percentages

As AnonyMonk notes, you've left us guessing about the nature of the rule(s) by which you are planning to derive your various products, namely:
percentage of "@sorted_array[0]" is 1%. result will be: @final_array[0]=1

Whatever your method is, it eludes me (and given the lack of answers on a day with few new question, possibly is a mystery to others as well) especially since there's no obvious (again, 'to me') common path for transforming

  • "@sorted_array[0], -150," to 1%
          and
  • "@sorted_array[3], 0," to 75%.

And then there is the trailing @final_array[5]=75 on line 7: Whence came that inexplicable entry? Is it a mere typo or cut'n'paste error or does it have some significance to your problem and if so, what? If it's somehow related to @sorted_array[5] (which is "2"), pray explain.

I won't claim that explanation is good for the soul, but yours would surely be a good aid to those of interesting in helping people learn Perl... which is one key to what this site is about. See I know what I mean. Why don't you?

Come, let us reason together: Spirit of the Monastery

If I've misconstrued your question or the logic needed to answer it, I offer my apologies to all those electrons which were inconvenienced by the creation of this post.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2024-04-23 08:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found