Skip to content

Instantly share code, notes, and snippets.

@nathggns
Created August 22, 2017 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathggns/5725595c24276e1ec62ae75ed23f8be0 to your computer and use it in GitHub Desktop.
Save nathggns/5725595c24276e1ec62ae75ed23f8be0 to your computer and use it in GitHub Desktop.
Prolog to create union of two lists without unifying non-ground terms
myUMember(X, [Y|T]) :- X == Y; myUMember(X, T).
myU([X|Y],Z,W) :-
myUMember(X,Z),
!,
myU(Y,Z,W).
myU([X|Y],Z,[X|W]) :- myU(Y,Z,W).
myU([],Z,Z).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment