Input two arrays of Vector x,y pair by x,y pair and find the function of the two x,y pairs output new array ...?
let v1 = [|for x, y in [3.,3.; 5.,5.; 1.,1.] -> Vector(x, y)|];;
let v2 = [|for x, y in [1.,1.; 2.,2.; 4.,4.] -> Vector(x, y)|];;
let data8 v1 v2 = Array.map2 (fun x y -> Vector.C开发者_JAVA百科rossProduct) v1 v2
val v1 : Vector [] = [|3,3; 5,5; 1,1|]
val v2 : Vector [] = [|1,1; 2,2; 4,4|]
val data8 : 'a [] -> 'b [] -> (Vector * Vector -> float) []
data8 v1 v2;; val it : (Vector * Vector -> float) [] = [|; ; |]
See: http://fpish.net/topic/Some/0/73895
You forgot to pass the arguments to Vector.CrossProduct:
let data8 v1 v2 = Array.map2 (fun x y -> Vector.CrossProduct(x, y)) v1 v2
精彩评论