Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: How to convert array key values into percentages

by ww (Bishop)
on Jan 26, 2014 at 21:01 UTC ( #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.


Comment on Re: How to convert array key values into percentages
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2014-09-17 03:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (57 votes), past polls