I’m trying to learn prolog and i bumpt in this error which, i don’t know why i get it so i am asking for your help.
code(TPROLOG#86):
trace
domains
item = integer
intList = item*
predicates
member(item,intList)
clauses
member(elm,[elm|_]).
member(elm,[_|T]):- %%% ***ELM is seen as wrong type, why?***
member(item,[T]).
goal
member(5,[1,2,3,4,5])
Any advice or hint is welcomed. Thank you.
You are confusing variables and atoms. Atoms start with a lower case letter, whereas variables start with an upper case letter.
Also, your
member/2definition seems wrong. It should read:First clause matches the element with the head of the second list. Second clause skips the head of the second list and recursively calls
member/2to find another match in the tail of the list.