0

the thing is that if for example i ask ?- maxC([1,2,3,4], K, M). it have to return:

K=0 M = [];
K=1 M = [1];
K=2 M = [1,2];
K=3 M = [1,2,3];
K=4 M =[1,2,3,4];
false.

But it doesn´t

maxC(_,0,[]). %->return empty when 0
maxC([H|_], 1,[H]).%-> return the last element
maxC([],_,[]). %-> return empty if list of entrance is empty
maxC([H|T],Nesimo,[H|T2]):- I is Nesimo - 1, maxC(T,I,T2),!.
false
  • 10,533
  • 12
  • 98
  • 192
  • This is ambiguous (why the word "max") - is it a duplicate of https://stackoverflow.com/a/71223756/17628336 – brebs May 03 '22 at 07:12

0 Answers0