Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- domains
- list = real*
- predicates
- top(list, real).
- min(real, real, real).
- count(list, real, real).
- minl(list,real).
- clauses
- min(X,Y,X):-X<Y,!.
- min(_,Y,Y).
- minl([],999):-!.
- minl([X],X):-write("Min = ",X),nl,write("Count = "),!.
- minl([X|T],R):-minl(T,R1),min(X,R1,R).
- count([], _, 0):-!.
- count([H|T], El, Kol):-H=El,count(T,El,Kol1),Kol=Kol1+1,!; count(T,El,Kol).
- top(List,Kol):-minl(List,Znach),count(List,Znach,Kol).
- goal
- top ( [6,4,1,1,8,2,1] ,X).
Advertisement
Add Comment
Please, Sign In to add comment