Bohtvaroh

Blogger - Scalaz Motivation - 11

Jun 1st, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.20 KB | None | 0 0
  1. def sum[T](xs: List[T])(implicit m: Monoid[T], fl: FoldLeft[List]): T =
  2.   fl.foldLeft(xs, m.mzero, m.mappend)
  3.  
  4. p(sum(List(1, 2, 3))) // prints ###> 6
  5. p(sum(List("lamb", "da"))) // prints ###> lambda
Advertisement
Add Comment
Please, Sign In to add comment