Why does prolog answer false to: member([5], [2, 5]).
?
Is there a way to work around it?
Any help will be greatly appreciated.
As described in the SWI Prolog documentation for member/2:
member(?Elem, ?List )
True if
Elem
is a member ofList
.
The predicate is member. It is not subset or sublist or subsequence. It succeeds if the first argument is a member (that is, an element) of the list given in the second argument. The element [5]
is not a member of the list [2, 5]
since the element [5]
isn't 2 and it isn't 5. However, [5]
would be a member of the list [2, [5]]
, so member([5], [2, [5]])
would succeed.