I obtain a specific list using findall, and then want to count the number of elements in it.
i.e.
huntingbreeds(List) :-
findall(Breedname, breed(Breedname,_,hunting), List).
This returns a need list of hunting dogs from my database [beagle, basset].
But now if i try count it using my new predicate:
list_length([] , 0 ).
list_length([_|Xs] , L ) :-
list_length(Xs,N) ,
L is N+1 .
with my query ?- list_length(huntingbreeds(List), Count).
This just returns false.
I thought I may need to use arg i.e.
?- list_length(arg(1,huntingbreeds(List),L), Count).
but again it returns false. Anyone know how i can get the list size? I know the function list_length works as if i give it:
?- list_length([1,2,3], Count).
I get Count = 3.
But just don't know how to pass it my list from the find result. I have tried putting the full findall statement in place of the huntingbreeds(List)
but that still does nothing.