0
交叉口[1; 2; 2; 3; 4; 4; 3] [2; 3] = [2; 2; 3; 3]ocaml的递归
没有与我的代码,因为它目前一些错误返回[2; 2],因为它不会与t2匹配,只有h2,有没有人有任何建议我应该考虑改变这个方向?
let rec intersection (l1: int list) (l2: int list) : int list =
begin match l1, l2 with
| h1::t1, h2::t2 -> if h1=h2 then h1::intersection t1 l2
else intersection t1 l2
| _ -> []
end
谢谢你的有用评论! (正式注明) – user