Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.41 KB | None | 0 0
  1. %Sa se testeze daca o lista are aspect de vale
  2.  
  3. check_valley([]).
  4. check_valley(L):-change_sign(L,0).
  5.  
  6.  
  7. change_sign([_|T],1):-T=[],!.
  8.  
  9. change_sign([H|[H1|T]],N):-
  10.   H>H1,
  11.   N=0,
  12.   vale_aux([H1|T],N).
  13.  
  14. change_sign([H|[H1|T]],N):-
  15.   H<H1,
  16.   N=0,
  17.   change_sign([H1|T],1).
  18.  
  19. change_sign([H|[H1|T]],N):-
  20.   H<H1,
  21.   N=1,
  22.   change_sign([H1|T],N).
  23.  
  24. change_sign([H|[H1|_]],N):-
  25.   H>H1,
  26.   N=1,
  27.   fail.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement