📜  点积 ocaml - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:06.197000             🧑  作者: Mango

代码示例1
let rec safe_dot_product (vect1: int list) (vect2: int list) : int option = 
  match (vect1, vect2) with
    | [],[] -> Some 0
    | [],_ -> None
    | _,[] -> None
    | (x::xs, y::ys) ->
      match safe_dot_product xs ys with
        | None -> None
        | Some m -> Some ((x*y) + m)