Advertisement
Teammasik

Paradigmas_prolog_lr4

May 25th, 2023
724
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.64 KB | Jokes | 0 0
  1. %deln([1, 2, 3, 4, 5, 6, 7], R).
  2. %delindex([1, 1, 1, 2, 2, 2, 2, 3, 4, 5, 5, 6, 7], R).
  3. %start([1,2,3,4,5,6,7,8,9,10], R).
  4. /*
  5. deln([],[]).
  6. deln([Xh|Xt],Y):-
  7. 0 is Xh mod 3,
  8. deln(Xt,Y).
  9. deln([Xh|Xt],[Xh|Yt]):-
  10. deln(Xt, Yt).
  11. */
  12.  
  13. /*
  14. delindex(_,[],[]).
  15.  
  16. delindex(N,[Xh|Xt],Y):-
  17.  0 =:= N mod 3,
  18.  N1 is N + 1,
  19.  delindex(N1,Xt,Y).
  20.  
  21. delindex(N,[Xh|Xt],[Xh|Yt]):-
  22.  N1 is N + 1,
  23.  delindex(N1, Xt, Yt).
  24.  
  25. start(X, R) :- delindex(1, X, R).
  26.  
  27. delindex(_,[],[]).*/
  28.  
  29.  
  30.  
  31. %delindex([Xh|Xt],Y):-
  32. % delindex(Xt,Y).
  33.  
  34. delindex([], []).
  35. delindex([A], [A]).
  36. delindex([H,A],[H,A]).
  37. delindex([H,A,_|T],[H,A|R]) :- delindex(T, R).
  38.  
  39.  
  40.  
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement