countEmpty([],0,[]). countEmpty([1|L],0,[1|L]). countEmpty([0|T],Cnew,L):-countEmpty(T,C,L),Cnew is C+1. %-------------------------------------------- listEmpty(_,[],[]). listEmpty(Index,[0|T],[[Index,C]|L]):-countEmpty([0|T],C,Lnew),I is Index+C,listEmpty(I,Lnew,L). listEmpty(Index,[1|T],L):-I is Index+1,listEmpty(I,T,L). %-------------------------------------------- removeSmallPlace([],_,[]). removeSmallPlace([[_,X]|T],K,L):-removeSmallPlace(T,K,L),X=M. minListIndex([[_,M]|T],Index,Min):-minListIndex(T,Index,Min),Min