The definition of this Prolog library predicate is:
union([], L, L).
union([Head|L1tail], L2, L3) :-
        memberchk(Head, L2),
        !,
        union(L1tail, L2, L3).
union([Head|L1tail], L2, [Head|L3tail]) :-
        union(L1tail, L2, L3tail).
   This predicate does not perform any type testing functions.
This predicate works properly for set operations only, so repeated elements and variable elements should not be used.
Success:
      union([1,2,3],[1,3],L).     (gives L=[2,1,3]).
Fail:
      union([1,2,3,2],[1,3],[1,2,3]).  % repeated elements