You need to add several elements that are used by the function sumto calculate:
type Foo(value:int) =
member x.Value = value
static member (+) (a:Foo, b:Foo) = Foo(a.Value + b.Value)
static member Zero = Foo(0)
static member DivideByInt(a:Foo, n:int) = Foo(a.Value / n)
The function sumstarts with the value returned Zero, and then adds the values Foousing the overloaded operator +( averageand then divides the result by an integer):
let a = Array.init 10 (fun n -> Foo(n))
let sum = Array.sum a
sum.Value
source
share