开发者

How does F# map2 iter2 ||> work with Vector?

开发者 https://www.devze.com 2023-04-12 01:29 出处:网络
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 ...?

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号