PetreAdi has asked for the wisdom of the Perl Monks concerning the following question:
I have the following array:
@array = (-150, -5, 50, 0, 7, 0, 2 ,4, 3, 8, -1)
How do i a make a new array(@final_array) that contains percentages of @array
For example
What would be the best and fastest way to get the the percentage of @array@sorted_array = (-150, -5, -1, 0, 0, 2, 3, 4, 7, 8, 50) The percentage of "@sorted_array[0]" is 1%. The result will be: @final_array[0]=1 The percentage of "@sorted_array[-1]" is 100%. The result will be: @final_array[2]=100 The percentage of "@sorted_array[3]" is 75%. The result will be: @final_array[3]=75;@final_array[5]=75
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to convert array key values into percentages (arithmetic)
by tye (Sage) on Jan 26, 2014 at 20:54 UTC | |
by PetreAdi (Sexton) on Jan 26, 2014 at 21:09 UTC | |
|
Re: How to convert array key values into percentages
by ww (Archbishop) on Jan 26, 2014 at 21:01 UTC | |
|
Re: How to convert array key values into percentages (maths)
by Anonymous Monk on Jan 26, 2014 at 20:28 UTC | |
|