0
votes

How can I use findall function in another function, I mean

subset(0, [], []).
subset(Len, [E|Tail], [E|NTail]):- succ(PLen, Len),(PLen > 0 -> subset(PLen, Tail, NTail) ; NTail=[]).
subset(Len, [_|Tail], NTail):- subset(Len, Tail, NTail).

This gives sublist of a list with N elements but I want to keep all result in a list,then I wrote

 result(N,List,Result):- findall3(Y,subset(N,List,Y),Result).

Howewer I get error, I am new in prolog, is this usage allowed or not, if not how can I obtain these sublist in a list, is there anyway?

1
Did you mean to type findall3? It's really findall/3 which means it is called findall and takes 3 arguments. - lurker
Oh sorry, Thank you . - MetuCeng

1 Answers

0
votes

You want is findall, not findall3.