comb2(_,[]). comb2([X|T],[X|Comb]):-comb2(T,Comb). comb2([_|T],[X|Comb]):-comb2(T,[X|Comb]). % use ?-comb2([1,2,3,4],[X,Y]) to generate combinations with two elements.