Advertisement
Guest User

Untitled

a guest
Jun 14th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.44 KB | None | 0 0
  1. ciag_aryt(L1) :- L1=[A,B],!.
  2. ciag_aryt(L1) :-L1=[A,B,C], C-B =:= B-A,!.
  3. ciag_aryt(L1) :-
  4.      L1=[A,B,C|T],
  5.        C-B =:= B-A,
  6.  
  7.     ciag_aryt([B,C|T]).
  8.  
  9. odleglosc(L1,W) :- ciag_aryt(L1), L1=[A,B|T], W is B-A.
  10.  
  11.  
  12. stw_ciag(L1,I,L2) :-  ciag_aryt(L1), odleglosc(L1,R), ciag(L1,I,R,L2).
  13.  
  14.  
  15.  
  16.  
  17. ciag(L1,I,R,L2) :- I=:=0, L2=L1,!.
  18. ciag(L1,I,R,L2) :- append(T,[H],L1), A is H+R, append(L1,[A],LW1),
  19.     I1 is I-1,
  20.     ciag(LW1,I1,R,L2).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement