I am trying to list a given number of elements i have stored in List , my code is as follows
er(Person,List) :- findall(A, descendant(Person, A), List).
when i type the code below into prolog i get all of the elements that match my query.
er(james,X).
What i am trying to achieve is ask prolog to list a given amount of element say for example
er(james,3).
Prolog will only return at most 3 element from the list . I researched a bit and found that i can use findnsols instead of the findall operator but i couldn't find a practical way to implement it in my code .
findnsols(Nth, A, descendant(Person, A), List).
the nth can be any number from 0 to 999. – user4172072