0
comment
comment
on 3/21/2015 9:29 AM
This blog post explains five F#-specific features who simplify and stabilize the implementation of vector algebra:
Custom operators
Inlining
Units of Measure
Type inference
Automatic generalization
We will use these features to define an infix dot product operator who is compile-time type-safe and generic.
Dot Product Operator Implementation
let inline (.*) xs ys = Seq.map2 (*) xs ys |> Seq.sum
The above line of code does not contain any type annotations. However, thanks to the F# compiler's built-in [...]