PonaFly

5 prolog

Oct 11th, 2016
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.35 KB | None | 0 0
  1.  
  2.  rib([]):-!.
  3.  rib(Lst):-
  4.  Lst=[H|T],
  5.  w(H),nl,
  6.  rib(T).
  7.  
  8.  w(0):- !.
  9.  w(K):-
  10.  write('*'),
  11.  K1 is K-1,w(K1).
  12.  
  13.  
  14.  rec_rev(Lst1,Lst2):-
  15. reverse(Lst2,Lst),
  16. f(Lst1,Lst).
  17.  
  18. f([],[]):-!.
  19.  
  20. f(Lst1,Lst2):-
  21. Lst1=[H1|T1],
  22. Lst2=[H2|T2],
  23. (
  24. (list(H1),
  25.  rec_rev(H1,H2),!,f(T1,T2)),!;
  26.  (list(H2),
  27.  rec_rev(H2,H1),!,f(T1,T2)),!;
  28. (H1=H2,!,f(T1,T2))).
Add Comment
Please, Sign In to add comment