i need to find a k-length subset of list in prolog, i have this function:
subset([], []).
subset([E|Tail], [E|NTail]):-
subset(Tail, NTail).
subset([_|Tail], NTail):-
subset(Tail, NTail).
and i apply another rule for the length of the list,
length(Xs,Size)
the problem is it is very slow because it search for all-length subset, is there a direct recursive definition for this k-length subset?
i searched for it for a week and cant find anything