Kimossab

[IA] - F6

Apr 18th, 2016
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.62 KB | None | 0 0
  1. %1
  2. pot(_,0,1):-!.
  3. pot(Base,Exp,Poten):-Y is Exp-1,pot(Base,Y,Pt),Poten is Base*Pt.
  4.  
  5. %3
  6. sum([L|[]],L):-!.
  7. sum([L|C],X):-sum(C,Y),X is L+Y.
  8. count([],0):-!.
  9. count([_|C],X):-count(C,Y),X is Y+1.
  10. media(X,L):-sum(L,S),count(L,C), X is S/C.
  11.  
  12. %2
  13. pred([],L,L):-!.
  14. pred([X|L1],L2,[X|L3]):-pred(L1,L2,L3).
  15. mist([X],[X]):-!.
  16. mist([X|C],L):-mist(C,L1),pred(L1,[X],L).
  17. igual([],[]):-!.
  18. igual([X|Cx],[X|Cl]):-igual(Cx,Cl).
  19. palindrome(X):-mist(X,L),igual(X,L).
  20.  
  21. %5
  22. colocar(X,[],[X]):-!.
  23. colocar(X,[L|C],[L|L3]):-X>L,colocar(X,C,L3),!.
  24. colocar(X,[L|C],[X|[L|C]]).
  25. ord([X|[]],[X]):-!.
  26. ord([X|C],L):-ord(C,L2),colocar(X,L2,L).
Add Comment
Please, Sign In to add comment