Bohtvaroh

Blogger - Scalaz Motivation - 9

Jun 1st, 2012
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.16 KB | None | 0 0
  1. //before
  2. // def sum(xs: List[Int]): Int = xs.foldLeft(0)(_ + _)
  3. // after
  4. def sum[T](xs: List[T])(implicit m: Monoid[T]): T = xs.foldLeft(m.mzero)(m.mappend)
Advertisement
Add Comment
Please, Sign In to add comment