Ada Generic Averaging Function -
i have function averages numeric value array of records. value either natural or enumerated type delta. have summing values correctly question this: how length of array generic type, can divide both integers , delta type numbers?
on array-of-records use 'length attribute; has advantage of working if bounds odd, -18..3, or enumeration, cheeses..fruits.
something like:
function average( input : in array_of_records ) return float -- have summation function, so... sum : natural:= summation( input ); begin return sum / input'length; end average;
you may need convert numeric types, saying float(sum) or like, ada no automatic type "promotions."
Comments
Post a Comment