3
votes

How to resolve this problem with type inference?

open Microsoft.FSharp.Linq.RuntimeHelpers
open System
open System.Linq.Expressions
open Accord.Math.Optimization

module Vector=
    let compareScalarProcut(a:double[])(b:double[])(greaterOrEqualThen:float)=
         Array.map2 (*) a b 
        |> Array.sum
        |> fun x-> x >= greaterOrEqualThen

module Lambda =
    let toExpression (``f# lambda`` : Quotations.Expr<'a>) =
        ``f# lambda``
        |> LeafExpressionConverter.QuotationToExpression 
        |> unbox<Expression<'a>>


let LambdaExpression (coefficients:double[]) = 
    <@ Func<double[], bool>(fun i -> (Vector.compareScalarProcut(i,coefficients,0)) @> 
    |> Lambda.toExpression

enter image description here

1

1 Answers

5
votes

You're calling your function incorrectly. It's a "normal" F# function that takes arguments separated by whitespace, instead of a tuple of arguments separated by commas. Try this instead:

Vector.compareScalarProcut i coefficients 0.0