このディレクトリの索引

#  Hi everyone, i'm having a bit of a problem with a prolog exercise.
#  
#  Assume i have a list of actors that have won oscars. Like this:
#  
#  (steven spielberg, steven spielberg, francis ford coppola, michael curtiz)
#  When a name appears two times, it means that the person won 2 oscars and so on.
#  What i need to do is to go trough this list and find every actor
#  that won N or more Oscars, with a predicate like
#  
#  wonMoreOscars(Number, Activity):-
#  Where the number is the N we have to compare with the list.
#  I already have a function that counts the person that occurs the more times
#  in a list and the activity the function that person has in the movie,
#  but is already covered.
#  
#  Can somebody help me, i have the code to find the person who has won more Oscars:
#  
#  occS([],_,_,_,_):-
#          write(0),nl,
#          write('+'),nl, !.
#  occS([H|T],_,_,_,_):-
#          occ([H|T],0,0,H,H).
#  occ([],_,Top,_,Nome):-
#          write(Nome),nl,
#          write(Top),nl,
#          write('+'),nl,!.
#  occ([H|T],Count,Top,El_corrente,_):-
#          compare(=,H,El_corrente),
#          C is Count +      1,
#          C>=Top,
#          occ(T,C,C,El_corrente,El_corrente), !.
#  occ([H|T],_,Top,El_corrente,Nome):-
#          not(compare(=,H,El_corrente)),
#          occ(T,1,Top,H,Nome),!.
#  occ([H|T],Count,Top,_,Nome):-
#          C is Count + 1,
#          occ(T,C,Top,H,Nome),!.
#  But now i'm having trouble with this case. Can somebody help me ? Thx in advance.

'Oscars'(['steven spielberg', 'steven spielberg', 'francis ford coppola', 'michael curtiz']).

wonMoreOscars(Number, Activity):-
        'Oscars'(L),
        setof(Name,member(Name,L),L1),
        findall([Name,Count],(
                    append(_,[Name|_],L1),
                    count(append(_,[Name|_],L),Count),
                    Count >= Number),
                Activity).

count(P,N) :-
        findall(1,P,L),
        length(L,N).