Closed adampingel closed 6 years ago
https://github.com/randomforestwhitaker/questions/blob/a607680fed8c614a478260e329b4412a57112903/answer_1.scala#L43-L45
This helper function would be more helpful if it were defined on empty lists. Check the incoming list's length. If it's zero, return Double.NaN.
Double.NaN
This would allow you to remove the check for Nil in resolver above.
Nil
resolver
Moved empty list handling logic to this average helper function instead of main resolver function.
https://github.com/randomforestwhitaker/questions/blob/a607680fed8c614a478260e329b4412a57112903/answer_1.scala#L43-L45
This helper function would be more helpful if it were defined on empty lists. Check the incoming list's length. If it's zero, return
Double.NaN
.This would allow you to remove the check for
Nil
inresolver
above.