daily pastebin goal
76%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. len(0, []).
  2. len(N, [_|B]) :- len(M, B), N is M+1.
  3.  
  4. head([X|_]) :- print(X).
  5. tail([_|X]) :- print(X).
  6.  
  7. memberx(X,[X|_]).
  8. memberx(X,[_|B]) :- memberx(X,B).
  9.  
  10. unionx([A|X],Y,[A|Z]) :- not(memberx(A,Y)), unionx(X,Y,Z).
  11. unionx([A|X],Y,Z) :- memberx(A,Y), unionx(X,Y,Z).
  12. unionx([],X,X).
  13.  
  14. intersectionx([A|X],Y,Z) :- not(memberx(A,Y)), intersectionx(X,Y,Z).
  15. intersectionx([A|X],Y,[A|Z]) :- memberx(A,Y), intersectionx(X,Y,Z).
  16. intersectionx([],_,[]).
  17.  
  18. differencex([A|X],Y,Z) :- memberx(A,Y), differencex(X,Y,Z).
  19. differencex([A|X],Y,[A|Z]) :- not(memberx(A,Y)), differencex(X,Y,Z).
  20. differencex([],_,[]).
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top