Using shapeless-spire to compute the average of data structures

18 views
Skip to first unread message

Edmondo Porcu

unread,
Jun 28, 2015, 5:29:32 AM6/28/15
to spire...@googlegroups.com
Hello,

I have a a data structure composed all by numerical values, so that for each member I can generate a semigroup

case class A(x:Int, y:Int)

Thanks to shapeless-spire one can auto generate monoids for this data structures. Is there a typeclass that performs the average (if exists) and how to autogenerate it?

 I have solved my problem by performing a reduce on the collection, adding the items and then dividing all the members properties of the final value by the length of the collection, but I am hoping for a more elegant solution


Reply all
Reply to author
Forward
0 new messages