Hi everybody, I'm a new user...and I hope that this forum can help me!!!
I've got a list composed by the following elements: (a,b,c,d,e,f,g,h,e)...(the 'e' char is present two times)
ok now I have to verify if the 'e' char belongs to the list. The code is very simple:
member(X,[X|_]).
member(X,[_|Y]):-member(X,Y).
The question to the prolog compiler is :
?-member(e,[a,b,c,d,e,f,g,e]).
In this way I can verify that the 'e' char belongs to the list.
My question is: How can I count the number of 'e' char in the list???
Thanks to all.
Andrea
I've got a list composed by the following elements: (a,b,c,d,e,f,g,h,e)...(the 'e' char is present two times)
ok now I have to verify if the 'e' char belongs to the list. The code is very simple:
member(X,[X|_]).
member(X,[_|Y]):-member(X,Y).
The question to the prolog compiler is :
?-member(e,[a,b,c,d,e,f,g,e]).
In this way I can verify that the 'e' char belongs to the list.
My question is: How can I count the number of 'e' char in the list???
Thanks to all.
Andrea