got the element part right but still not sure about the atom part.
len([],0).
len([_|T],N) :- len(T,M),N is M+1.
?- len([[1,2],[3,4],4,5]).
X = 3;
Atoms should be X = 6;
any help or where can I look on the web?
% 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).
?-...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.