Reputation: 147
I have a recursive predicate call, and the output of that call is appended to a list with append/3
. So the output is going to be a list of lists. My problem is, that sometimes the append/3
gets called something like this:
append([[2]], [1,2,3,4], L).
And the output of this is [[2], 1,2,3,4]
. I would like to check before the append/3
that the first element is a list of lists with only one element, but so far I was unable to create a pattern that matches it.
So my question is: how can I check if something is a list of a list?
Upvotes: 0
Views: 781
Reputation: 726549
The rule that matches a Prolog atom is, well, atom/1
:
is_list_of_list_with_one_element([[X]]) :- atom(X).
Upvotes: 1