2
votes

I'm trying to write a query that will make sure an element is present in a list of lists, I tried this implementation:

membernested(E,[H|T]):-member(E,H).
membernested(E,[H|T]):-membernested(E,[T]).

but Prolog won't answer the query, any thoughts?

1

1 Answers

1
votes

Change you second clause to:

membernested(E,[H|T]) :- membernested(E,T).

The tail of the list [H|T] is T, not [T]. There's no need to enclose it in another list.