Untitled

mail@pastecode.io avatar
unknown
ocaml
2 years ago
335 B
0
Indexable
Never
let rec member x = function
  | [] -> false
  | y::l ->
      if x = y then true
      else member x l;;

let rec inner_union xs ys u =
  match xs with
    [] -> u
  | xs::xss when member xs ys && not(member xs u) -> inner_union xss ys (xs::u)
  | xs::xss -> inner_union xss ys u;;

let union xs ys = inner_union xs ys [];;