Skip to content

Instantly share code, notes, and snippets.

@xxxnell
Created June 24, 2018 17:12
Show Gist options
  • Save xxxnell/40956ebcacb114bb7ecf22933caa584c to your computer and use it in GitHub Desktop.
Save xxxnell/40956ebcacb114bb7ecf22933caa584c to your computer and use it in GitHub Desktop.
def mean[A](as: List[A])(implicit frac: Fractional[A]): A =
if (as.nonEmpty) frac.div(as.sum, frac.fromInt(as.length)) else frac.zero
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment