Don't ask to ask, just ask | |
PerlMonks |
Re: Finding Median of an Array after an Infinite Loopby BillKSmith (Monsignor) |
on Nov 27, 2019 at 21:07 UTC ( [id://11109326]=note: print w/replies, xml ) | Need Help?? |
Did you search ? You will find several modules that will do the computation for you. Even if you do not use them, they should be great examples. If you wish to do it yourself for the learning experience, sort the array. (Be sure to use numeric sort. It is not the default) If you have an odd number of elements, choose the middle one. Otherwise, take the average of the middle two elements. You will probably find the function int useful in finding the middle.
Bill
In Section
Seekers of Perl Wisdom
|
|