ChameL1oN

ЯП3_1

Jun 6th, 2015
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. domains
  2. list = real*
  3.  
  4. predicates
  5. top(list, real).
  6. min(real, real, real).
  7. count(list, real, real).
  8. minl(list,real).
  9.  
  10. clauses
  11. min(X,Y,X):-X<Y,!.
  12. min(_,Y,Y).
  13.  
  14. minl([],999):-!.
  15. minl([X],X):-write("Min = ",X),nl,write("Count = "),!.
  16. minl([X|T],R):-minl(T,R1),min(X,R1,R).
  17.  
  18. count([], _, 0):-!.
  19. count([H|T], El, Kol):-H=El,count(T,El,Kol1),Kol=Kol1+1,!; count(T,El,Kol).
  20.  
  21. top(List,Kol):-minl(List,Znach),count(List,Znach,Kol).
  22.  
  23.  
  24. goal
  25. top ( [6,4,1,1,8,2,1] ,X).
Advertisement
Add Comment
Please, Sign In to add comment