johanprolog
Programmer
% to get elements in list
mymember(X,[X|_]).
mymember(X,[_|T]) :- mymember(X , T).
?- mymember(X,[a,b,[1,2,3],c]).
X = a ;
X = b ;
X = [1, 2, 3] ;
X = c ;
%to get atoms in list.
mymember(X,[X|_]).
mymember(X,[_|T]) :- mymember(X , T).
mymember(X,[H|_]) :- mymember(X , H).
?- mymember(X,[a,b,[1,2,3],c]).
X = a ;
X = b ;
X = [1, 2, 3] ;
X = c ;
X = 1 ;
X = 2 ;
X = 3 ;
i need to count the elements and atoms what do I need to add
to the code to get the count?
Thnx Johan
mymember(X,[X|_]).
mymember(X,[_|T]) :- mymember(X , T).
?- mymember(X,[a,b,[1,2,3],c]).
X = a ;
X = b ;
X = [1, 2, 3] ;
X = c ;
%to get atoms in list.
mymember(X,[X|_]).
mymember(X,[_|T]) :- mymember(X , T).
mymember(X,[H|_]) :- mymember(X , H).
?- mymember(X,[a,b,[1,2,3],c]).
X = a ;
X = b ;
X = [1, 2, 3] ;
X = c ;
X = 1 ;
X = 2 ;
X = 3 ;
i need to count the elements and atoms what do I need to add
to the code to get the count?
Thnx Johan