I have a list in prolog like this: [a,b,c,d,e].
Then the idea is to exam every 3 items like [a,b,c]; do something with a and c, then store b. The same goes for [b,c,d], and [c,d,e]... until I run out of the combination of 3.
How does the recursion work here? I tried something below but could not figure out how to safely exit and/or preserve the list M
% write(M). gave memo address
%[_,_] will be caught if there are less than 3 items in the list
con([_,_],M) :- M.
con([a,b|[c|T]],M) :-
a < b,
con([b|[c|T]],[b|M]).
con([a,b|[c|T]],M) :-
a > b,
con([b|[c|T]],[b|M]).