Advertisement
sb8623

cut.pl

Apr 18th, 2023
1,716
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.44 KB | Source Code | 0 0
  1. f(X, 0):-
  2.     X < 3, !.
  3. f(X, 1):-
  4.     X < 6, !.
  5. f(X, 2).
  6. %red cut green cut
  7.  
  8. %maximum of two numbers
  9. %without cut
  10. max(X, Y, X):-
  11.     X >= Y.
  12. max(X, Y, Y):-
  13.     X < Y.
  14.  
  15. %with cut
  16. max_cut(X, Y, X):-
  17.     X >= Y, !.
  18. max_cut(X, Y, Y).
  19.  
  20. %member function with cut
  21. member(X, [X | _ ]) :- !.
  22.  
  23. member(X, [Y | Rest]):-
  24.     member(X, Rest).
  25.  
  26. %add an element to an list without duplication
  27. add(X,L,L):- member(X, L), !.
  28. add(X, L, [X|L]).
  29.  
  30.  
Tags: pl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement